import { GroupEncryptionAlgorithmId, GroupEncryptionSession } from './olmLib'; import { EncryptionDevice } from './encryptionDevice'; import { EncryptedData } from '@towns-protocol/proto'; export interface IGroupEncryptionClient { encryptAndShareGroupSessionsToStream(streamId: string, sessions: GroupEncryptionSession[], algorithm: GroupEncryptionAlgorithmId, priorityUserIds: string[]): Promise; getMiniblockInfo(streamId: string): Promise<{ miniblockNum: bigint; miniblockHash: Uint8Array; }>; } export interface IDecryptionParams { /** olm.js wrapper */ device: EncryptionDevice; } export interface IEncryptionParams { client: IGroupEncryptionClient; /** olm.js wrapper */ device: EncryptionDevice; } export interface EnsureOutboundSessionOpts { shareShareSessionTimeoutMs?: number; priorityUserIds?: string[]; miniblockInfo?: { miniblockNum: bigint; miniblockHash: Uint8Array; }; } /** * base type for encryption implementations */ export declare abstract class EncryptionAlgorithm implements IEncryptionParams { readonly device: EncryptionDevice; readonly client: IGroupEncryptionClient; /** * @param params - parameters */ constructor(params: IEncryptionParams); abstract ensureOutboundSession(streamId: string, opts?: EnsureOutboundSessionOpts): Promise; abstract hasOutboundSession(streamId: string): Promise; abstract encrypt_deprecated_v0(streamId: string, payload: string): Promise; abstract encrypt(streamId: string, payload: Uint8Array): Promise; } /** * base type for decryption implementations */ export declare abstract class DecryptionAlgorithm implements IDecryptionParams { readonly device: EncryptionDevice; constructor(params: IDecryptionParams); abstract decrypt(streamId: string, content: EncryptedData): Promise; abstract importStreamKey(streamId: string, session: GroupEncryptionSession): Promise; abstract exportGroupSession(streamId: string, sessionId: string): Promise; abstract exportGroupSessions(): Promise; abstract exportGroupSessionIds(streamId: string): Promise; abstract hasSessionKey(streamId: string, sessionId: string): Promise; } /** * Exception thrown when decryption fails * * @param msg - user-visible message describing the problem * * @param details - key/value pairs reported in the logs but not shown * to the user. */ export declare class DecryptionError extends Error { readonly code: string; constructor(code: string, msg: string); } export declare function isDecryptionError(e: Error): e is DecryptionError; //# sourceMappingURL=base.d.ts.map