import type { sdk } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js"; import type { TableSettings } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/tables/TableSettings.js"; import type { TableSyncState } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/tables/TableSyncState.js"; import type { TableUser } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/tables/TableUser.js"; import { Zip, ZipDeflate } from "fflate"; type AuthId = sdk.AuthId; type ProcessSyncChunkResult = sdk.ProcessSyncChunkResult; type RequestSyncChunkArgs = sdk.RequestSyncChunkArgs; type SyncChunk = sdk.SyncChunk; type WalletStorageProvider = sdk.WalletStorageProvider; type WalletServices = sdk.WalletServices; /** * FileBackupProvider implements WalletStorageProvider to receive sync chunks * during wallet export. It encodes each chunk with MessagePack and streams * it directly to a fflate Zip instance. * * Usage: * 1. Create fflate.Zip with streaming callback * 2. Create FileBackupProvider with the zip instance * 3. Call storage.syncToWriter(auth, provider) * 4. Provider receives processSyncChunk() calls and writes to zip * 5. Call provider.getChunkCount() to get chunk count for manifest * * @example * ```typescript * import { Zip } from 'fflate'; * * const chunks: Uint8Array[] = []; * const zip = new Zip((err, data, final) => { * if (err) throw err; * chunks.push(data); * if (final) { * const blob = new Blob(chunks, { type: 'application/zip' }); * // Download or save blob * } * }); * * const provider = new FileBackupProvider(zip, storage.getSettings(), identityKey); * await storage.syncToWriter(auth, provider); * console.log(`Exported ${provider.getChunkCount()} chunks`); * ``` */ export declare class FileBackupProvider implements WalletStorageProvider { private zip; private chunkCount; private settings; private identityKey; constructor(zip: Zip, settings: TableSettings, identityKey: string); /** * Get the number of chunks written. Call after sync completes. */ getChunkCount(): number; /** * Add a file to the zip archive with compression. * Creates a ZipDeflate stream and pushes the data in one chunk. */ private addFileToZip; isStorageProvider(): boolean; setServices(_v: WalletServices): void; findOrInsertSyncStateAuth(_auth: AuthId, _storageIdentityKey: string, _storageName: string): Promise<{ syncState: TableSyncState; isNew: boolean; }>; setActive(_auth: AuthId, _newActiveStorageIdentityKey: string): Promise; getSyncChunk(_args: RequestSyncChunkArgs): Promise; /** * Receives sync chunks from WalletStorageManager.syncToWriter(). * Encodes each chunk with MessagePack and adds to the zip. */ processSyncChunk(_args: RequestSyncChunkArgs, chunk: SyncChunk): Promise; makeAvailable(): Promise; migrate(_storageName: string, _storageIdentityKey: string): Promise; destroy(): Promise; findOrInsertUser(identityKey: string): Promise<{ user: TableUser; isNew: boolean; }>; abortAction(_auth: AuthId, _args: unknown): Promise; createAction(_auth: AuthId, _args: unknown): Promise; processAction(_auth: AuthId, _args: unknown): Promise; internalizeAction(_auth: AuthId, _args: unknown): Promise; insertCertificateAuth(_auth: AuthId, _certificate: unknown): Promise; relinquishCertificate(_auth: AuthId, _args: unknown): Promise; relinquishOutput(_auth: AuthId, _args: unknown): Promise; isAvailable(): boolean; getServices(): WalletServices; getSettings(): TableSettings; findCertificatesAuth(_auth: AuthId, _args: unknown): Promise; findOutputBasketsAuth(_auth: AuthId, _args: unknown): Promise; findOutputsAuth(_auth: AuthId, _args: unknown): Promise; findProvenTxReqs(_args: unknown): Promise; listActions(_auth: AuthId, _vargs: unknown): Promise; listCertificates(_auth: AuthId, _vargs: unknown): Promise; listOutputs(_auth: AuthId, _vargs: unknown): Promise; } export { Zip, ZipDeflate };