import { EncryptedData, ExportedDevice } from '@towns-protocol/proto'; import { GroupEncryptionAlgorithmId, GroupEncryptionSession, UserDevice } from './olmLib'; import { DecryptionAlgorithm, EncryptionAlgorithm, EnsureOutboundSessionOpts, IGroupEncryptionClient } from './base'; import { type EncryptionDeviceInitOpts } from './encryptionDevice'; import type { CryptoStore } from './cryptoStore'; export interface ImportRoomKeysOpts { /** Reports ongoing progress of the import process. Can be used for feedback. */ progressCallback?: (stage: ImportRoomKeyProgressData) => void; } /** * Room key import progress report. * Used when calling {@link GroupEncryptionCrypto#importRoomKeys} or * {@link GroupEncryptionCrypto#importRoomKeysAsJson} as the parameter of * the progressCallback. Used to display feedback. */ export interface ImportRoomKeyProgressData { stage: string; successes?: number; failures?: number; total?: number; } export declare class GroupEncryptionCrypto { private delegate; private readonly encryptionDevice; readonly groupEncryption: Record; readonly groupDecryption: Record; readonly cryptoStore: CryptoStore; globalBlacklistUnverifiedDevices: boolean; globalErrorOnUnknownDevices: boolean; constructor(client: IGroupEncryptionClient, cryptoStore: CryptoStore); /** Iniitalize crypto module prior to usage * */ init(opts?: EncryptionDeviceInitOpts): Promise; /** * Encrypt an event using the device keys * * @param payload - string to be encrypted * @param deviceKeys - recipients to encrypt message for * * @returns Promise which resolves when the event has been * encrypted, or null if nothing was needed */ encryptWithDeviceKeys(payload: string, deviceKeys: UserDevice[]): Promise>; /** * Decrypt a received event using the device key * * @returns a promise which resolves once we have finished decrypting. * Rejects with an error if there is a problem decrypting the event. */ decryptWithDeviceKey(ciphertext: string, senderDeviceKey: string): Promise; /** * Ensure that we have an outbound group session key for the given stream * * @returns Promise which resolves when the event has been * created, use options to await the initial share */ ensureOutboundSession(streamId: string, algorithm: GroupEncryptionAlgorithmId, opts?: EnsureOutboundSessionOpts): Promise; /** * * @param streamId - the id of the stream to check * @param algorithm - the algorithm to use * @returns true if the stream has an outbound session, false otherwise */ hasOutboundSession(streamId: string, algorithm: GroupEncryptionAlgorithmId): Promise; /** * Encrypt an event using group encryption algorithm * * @returns Promise which resolves when the event has been * encrypted, or null if nothing was needed */ encryptGroupEvent(streamId: string, payload: Uint8Array, algorithm: GroupEncryptionAlgorithmId): Promise; /** * Deprecated uses v0 encryption version * * @returns Promise which resolves when the event has been * encrypted, or null if nothing was needed */ encryptGroupEvent_deprecated_v0(streamId: string, payload: string, algorithm: GroupEncryptionAlgorithmId): Promise; /** * Decrypt a received event using group encryption algorithm * * @returns a promise which resolves once we have finished decrypting. * Rejects with an error if there is a problem decrypting the event. */ decryptGroupEvent(streamId: string, content: EncryptedData): Promise>; exportGroupSession(streamId: string, sessionId: string): Promise; /** */ exportRoomKeys(): Promise; /** */ getGroupSessionIds(streamId: string): Promise; /** */ hasSessionKey(streamId: string, sessionId: string, algorithm: GroupEncryptionAlgorithmId): Promise; /** */ getUserDevice(): UserDevice; /** */ exportDevice(): Promise; /** * Import a list of group session keys previously exported by exportRoomKeys * * @param streamId - the id of the stream the keys are for * @param keys - a list of session export objects * @returns a promise which resolves once the keys have been imported */ importSessionKeys(streamId: string, keys: GroupEncryptionSession[]): Promise; /** * Import a list of room keys previously exported by exportRoomKeys * * @param keys - a list of session export objects * @returns a promise which resolves once the keys have been imported */ importRoomKeys(keys: GroupEncryptionSession[], opts?: ImportRoomKeysOpts): Promise; /** * Import a JSON string encoding a list of room keys previously * exported by exportRoomKeysAsJson * * @param keys - a JSON string encoding a list of session export * objects, each of which is an GroupEncryptionSession * @param opts - options object * @returns a promise which resolves once the keys have been imported */ importRoomKeysAsJson(keys: string): Promise; hasHybridSession(streamId: string): Promise; } //# sourceMappingURL=groupEncryptionCrypto.d.ts.map