import { ChatEvent, ChatResponse, T } from "@simplex-chat/types"; /** * Initialize chat controller */ export declare function chatMigrateInit(dbPath: string, dbKey: string, confirm: MigrationConfirmation): Promise; /** * Close chat store */ export declare function chatCloseStore(ctrl: bigint): Promise; /** * Send chat command as string */ export declare function chatSendCmd(ctrl: bigint, cmd: string): Promise; /** * Receive chat event */ export declare function chatRecvMsgWait(ctrl: bigint, wait: number): Promise; /** * Write buffer to encrypted file */ export declare function chatWriteFile(ctrl: bigint, path: string, buffer: ArrayBuffer): Promise; /** * Read buffer from encrypted file */ export declare function chatReadFile(path: string, { fileKey, fileNonce }: CryptoArgs): Promise; /** * Encrypt file */ export declare function chatEncryptFile(ctrl: bigint, fromPath: string, toPath: string): Promise; /** * Decrypt file */ export declare function chatDecryptFile(fromPath: string, { fileKey, fileNonce }: CryptoArgs, toPath: string): Promise; export interface APIResult { result?: R; error?: T.ChatError; } export declare class ChatAPIError extends Error { message: string; chatError: T.ChatError | undefined; constructor(message: string, chatError?: T.ChatError | undefined); } /** * Migration confirmation mode */ export declare enum MigrationConfirmation { YesUp = "yesUp", YesUpDown = "yesUpDown", Console = "console", Error = "error" } /** * File encryption key and nonce */ export interface CryptoArgs { fileKey: string; fileNonce: string; } export declare class ChatInitError extends Error { message: string; dbMigrationError: DBMigrationError; constructor(message: string, dbMigrationError: DBMigrationError); } export type DBMigrationError = DBMigrationError.InvalidConfirmation | DBMigrationError.ErrorNotADatabase | DBMigrationError.ErrorMigration | DBMigrationError.ErrorSQL; export declare namespace DBMigrationError { export type Tag = "invalidConfirmation" | "errorNotADatabase" | "errorMigration" | "errorSQL"; interface Interface { type: Tag; } export interface InvalidConfirmation extends Interface { type: "invalidConfirmation"; } export interface ErrorNotADatabase extends Interface { type: "errorNotADatabase"; dbFile: string; } export interface ErrorMigration extends Interface { type: "errorMigration"; dbFile: string; migrationError: MigrationError; } export interface ErrorSQL extends Interface { type: "errorSQL"; dbFile: string; migrationSQLError: string; } export {}; } export type MigrationError = MigrationError.MEUpgrade | MigrationError.MEDowngrade | MigrationError.MigrationError; export declare namespace MigrationError { export type Tag = "upgrade" | "downgrade" | "migrationError"; interface Interface { type: Tag; } export interface MEUpgrade extends Interface { type: "upgrade"; upMigrations: UpMigration; } export interface MEDowngrade extends Interface { type: "downgrade"; downMigrations: string[]; } export interface MigrationError extends Interface { type: "migrationError"; mtrError: MTRError; } export {}; } export interface UpMigration { upName: string; withDown: boolean; } export type MTRError = MTRError.MTRENoDown | MTRError.MTREDifferent; export declare namespace MTRError { export type Tag = "noDown" | "different"; interface Interface { type: Tag; } export interface MTRENoDown extends Interface { type: "noDown"; upMigrations: UpMigration; } export interface MTREDifferent extends Interface { type: "different"; downMigrations: string[]; } export {}; }