matrix-js-sdk
Version:
Matrix Client-Server SDK for Javascript
70 lines • 2.98 kB
TypeScript
import { OlmMachine } from "@matrix-org/matrix-sdk-crypto-wasm";
import { BackupTrustInfo, KeyBackupCheck, KeyBackupInfo } from "../crypto-api/keybackup";
import { IHttpOpts, MatrixHttpApi } from "../http-api";
import { CryptoEvent } from "../crypto";
import { TypedEventEmitter } from "../models/typed-event-emitter";
import { OutgoingRequestProcessor } from "./OutgoingRequestProcessor";
/**
* @internal
*/
export declare class RustBackupManager extends TypedEventEmitter<RustBackupCryptoEvents, RustBackupCryptoEventMap> {
private readonly olmMachine;
private readonly http;
private readonly outgoingRequestProcessor;
/** Have we checked if there is a backup on the server which we can use */
private checkedForBackup;
private activeBackupVersion;
private stopped;
/** whether {@link backupKeysLoop} is currently running */
private backupKeysLoopRunning;
constructor(olmMachine: OlmMachine, http: MatrixHttpApi<IHttpOpts & {
onlyData: true;
}>, outgoingRequestProcessor: OutgoingRequestProcessor);
/**
* Tells the RustBackupManager to stop.
* The RustBackupManager is scheduling background uploads of keys to the backup, this
* call allows to cancel the process when the client is stoppped.
*/
stop(): void;
/**
* Get the backup version we are currently backing up to, if any
*/
getActiveBackupVersion(): Promise<string | null>;
/**
* Determine if a key backup can be trusted.
*
* @param info - key backup info dict from {@link MatrixClient#getKeyBackupVersion}.
*/
isKeyBackupTrusted(info: KeyBackupInfo): Promise<BackupTrustInfo>;
/**
* Re-check the key backup and enable/disable it as appropriate.
*
* @param force - whether we should force a re-check even if one has already happened.
*/
checkKeyBackupAndEnable(force: boolean): Promise<KeyBackupCheck | null>;
private keyBackupCheckInProgress;
/** Helper for `checkKeyBackup` */
private doCheckKeyBackup;
private enableKeyBackup;
/**
* Restart the backup key loop if there is an active trusted backup.
* Doesn't try to check the backup server side. To be called when a new
* megolm key is known locally.
*/
maybeUploadKey(): Promise<void>;
private disableKeyBackup;
private backupKeysLoop;
/**
* Get information about the current key backup from the server
*
* @returns Information object from API or null if there is no active backup.
*/
private requestKeyBackupVersion;
}
export type RustBackupCryptoEvents = CryptoEvent.KeyBackupStatus | CryptoEvent.KeyBackupSessionsRemaining | CryptoEvent.KeyBackupFailed;
export type RustBackupCryptoEventMap = {
[CryptoEvent.KeyBackupStatus]: (enabled: boolean) => void;
[CryptoEvent.KeyBackupSessionsRemaining]: (remaining: number) => void;
[CryptoEvent.KeyBackupFailed]: (errCode: string) => void;
};
//# sourceMappingURL=backup.d.ts.map