import { type OTAVersionCheckResult } from './otaVersionChecker'; type RollbackCallback = (record: RollbackHistoryRecord) => void; /** * A single rollback history record. * Stored on-device every time a rollback is performed (crash or manual). */ export interface RollbackHistoryRecord { /** Unix timestamp in milliseconds when the rollback occurred */ timestamp: number; /** The OTA version that was active before the rollback */ fromVersion: string; /** * The version that was restored. * "original" means the original app bundle (no OTA). */ toVersion: string; /** * Why the rollback happened. * "crash_detected" — automatic crash handler triggered rollback * "manual" — user called rollbackToPreviousBundle() * "max_rollbacks_exceeded" — rollback counter > 3; reset to original bundle * Any other string — custom reason passed to markCurrentBundleAsBad() */ reason: 'crash_detected' | 'manual' | 'max_rollbacks_exceeded' | string; } /** * Target versions for OTA updates */ export interface OTATargetVersions { /** List of Android app versions this OTA can be safely installed on. Leave empty to target all versions */ android?: string[]; /** List of iOS app versions this OTA can be safely installed on. Leave empty to target all versions */ ios?: string[]; } /** * OTA version configuration structure for ota.version.json */ export interface OTAVersionConfig { /** The OTA version identifier */ version: string; /** Target app versions for different platforms */ targetVersions?: OTATargetVersions; /** Whether the version follows semantic versioning (x.y.z format). Defaults to false */ isSemver?: boolean; /** Optional release notes for this OTA update */ releaseNotes?: string; } export declare function checkForOTAUpdates(versionCheckUrl: string): Promise; export declare function downloadZipFromUrl(downloadUrl: string, onProgress?: (received: number, total: number) => void, bundleFilePath?: string): Promise; export declare function getStoredOtaVersion(): string | null; export declare function getStoredUnzippedPath(): string | null; export declare function reloadApp(): void; /** * Rollback to the previous OTA bundle. * * Blacklists the current (bad) version so it is never re-downloaded. * Increments the consecutive rollback counter. If the counter exceeds 3, * all OTA data is cleared and the original app bundle will be used on next launch. * Call reloadApp() after this to apply the change. * * @returns true if rollback succeeded (previous bundle activated or reset to original) */ export declare function rollbackToPreviousBundle(): Promise; /** * Confirm that the current OTA bundle is working correctly. * * Call this after verifying that critical app flows work on the new bundle * (e.g., after a successful login or key screen load). Once confirmed, the * automatic crash-rollback guard is disabled for this bundle — future crashes * will not trigger a rollback. * * If you never call this after a new bundle is applied, the crash handler will * roll back the bundle if the app crashes on the next launch. */ export declare function confirmBundle(): void; /** * Returns the list of blacklisted OTA version strings. * Blacklisted versions will never be downloaded again. */ export declare function getBlacklistedVersions(): Promise; /** * Returns the rollback history. * Each entry records one rollback event (crash or manual). */ export declare function getRollbackHistory(): Promise; /** * Manually marks the current bundle as bad, blacklists it, and triggers a rollback. * Call reloadApp() after this to apply. * @param reason - A description of why the bundle is being marked as bad */ export declare function markCurrentBundleAsBad(reason: string): Promise; /** * Subscribe to rollback events. * * The callback is fired in two situations: * 1. **Crash rollback from the previous session** — if the crash handler * rolled back the bundle before JS started (detected on first call by * inspecting the persisted rollback history). * 2. **Manual rollback in the current session** — when * `rollbackToPreviousBundle()` or `markCurrentBundleAsBad()` is called * and succeeds. * * @param callback - Receives the `RollbackHistoryRecord` describing the rollback. * @returns An unsubscribe function. Call it to remove the listener. * * @example * ```typescript * const unsubscribe = onRollback((record) => { * console.log('Rollback!', record.reason, record.fromVersion, '→', record.toVersion); * }); * // Later: * unsubscribe(); * ``` */ export declare function onRollback(callback: RollbackCallback): () => void; /** * Gets the current app version from the native bundle * Note: This requires react-native-device-info or similar package to be installed * If not available, returns a default version */ export declare function getAppVersion(): string; /** * Checks for OTA updates with enhanced version comparison * Supports both plain text (ota.version) and JSON (ota.version.json) formats * * @param versionCheckUrl - URL to check for version information * @param appVersion - Optional app version (auto-detected if not provided) * @returns OTAVersionCheckResult with detailed update information */ export declare function checkForOTAUpdatesJS(versionCheckUrl?: string, appVersion?: string): Promise; /** * Simple check for compatible OTA updates (backward compatible API) * @param versionCheckUrl - URL to check for version information * @param appVersion - Optional app version (auto-detected if not provided) * @returns true if a compatible update is available, false otherwise */ export declare function hasOTAUpdate(versionCheckUrl?: string, appVersion?: string): Promise; /** * OTA Update Manager class for handling over-the-air updates */ export declare class OTAUpdateManager { private downloadUrl; private versionCheckUrl?; constructor(downloadUrl: string, versionCheckUrl?: string); /** * Checks if there are any updates available by comparing versions */ checkForUpdates(): Promise; /** * Checks for updates using JS implementation with detailed version comparison * @param appVersion - Optional app version (auto-detected if not provided) * @returns Detailed version check result */ checkForUpdatesJS(appVersion?: string): Promise; /** * Simple check for compatible updates (backward compatible) * @param appVersion - Optional app version (auto-detected if not provided) * @returns true if a compatible update is available */ hasCompatibleUpdate(appVersion?: string): Promise; /** * Downloads and extracts the OTA update. * @param onProgress - Optional callback invoked with (bytesReceived, totalBytes) * during the download. `totalBytes` is -1 if the server does not send Content-Length. */ downloadUpdate(onProgress?: (received: number, total: number) => void, bundleFilePath?: string): Promise; /** * Gets the current stored OTA version */ getVersion(): string | null; /** * Gets the stored unzipped path */ getUnzippedPath(): string | null; /** * Reloads the app */ reloadApp(): void; /** * Rollback to the previous OTA bundle. * Blacklists the current version so it is not re-downloaded. * Call reloadApp() after this to apply the change. * @returns true if rollback was applied */ rollback(): Promise; /** * Confirm the current OTA bundle is working correctly. * Disables the automatic crash-rollback guard for this bundle. * Call this after verifying critical flows work on the new bundle. */ confirm(): void; /** * Returns the list of blacklisted OTA version strings. */ getBlacklist(): Promise; /** * Returns the rollback history. */ getHistory(): Promise; /** * Manually marks the current bundle as bad, blacklists it, and triggers a rollback. * Call reloadApp() after this to apply. * @param reason - Why the bundle is being marked as bad (default: 'manual') */ markAsBad(reason?: string): Promise; /** * Subscribe to rollback events for this manager's bundle. * * Fires when: * - A crash rollback happened in the previous session (detected on registration). * - `rollback()` or `markAsBad()` is called in the current session. * * @param callback - Receives the `RollbackHistoryRecord` of the rollback event. * @returns An unsubscribe function. */ onRollback(callback: (record: RollbackHistoryRecord) => void): () => void; /** * Schedule a background OTA check that runs natively (no JavaScript callbacks needed). * * @param interval - Delay in seconds before the check runs * * Note: * - Android: Uses WorkManager, works even when app is closed * - iOS: Uses background tasks, behavior depends on iOS version and permissions * - Safe to call multiple times (replaces existing scheduled tasks) * - URLs are passed from JavaScript (doesn't rely on stored preferences) * * @example * ```typescript * const manager = new OTAUpdateManager(downloadUrl, versionCheckUrl); * manager.scheduleBackgroundCheck(3600); // Check every hour * ``` */ scheduleBackgroundCheck(interval: number): void; } export { githubOTA } from './githubUtils'; export type { OTAVersionCheckResult } from './otaVersionChecker'; export { checkOTAVersion, hasCompatibleUpdate as checkCompatibleUpdate, } from './otaVersionChecker'; //# sourceMappingURL=index.d.ts.map