@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
78 lines • 2.95 kB
TypeScript
import type { DeviceId, DeviceInfo, FirmwareUpdateContext } from "@ledgerhq/types-live";
import { Observable } from "rxjs";
import { SharedTaskEvent } from "./core";
export type UpdateFirmwareTaskArgs = {
deviceId: DeviceId;
updateContext: FirmwareUpdateContext;
};
export type UpdateFirmwareTaskError = "DeviceOnDashboardExpected" | "DeviceOnBootloaderExpected" | "McuVersionNotFound" | "TooManyMcuOrBootloaderFlashes";
export type UpdateFirmwareTaskEvent = {
type: "installingOsu";
progress: number;
} | {
type: "flashingMcu";
progress: number;
} | {
type: "flashingBootloader";
progress: number;
} | {
type: "firmwareUpdateCompleted";
updatedDeviceInfo: DeviceInfo;
} | {
type: "installOsuDevicePermissionRequested";
} | {
type: "installOsuDevicePermissionGranted";
} | {
type: "installOsuDevicePermissionDenied";
} | {
type: "allowSecureChannelRequested";
} | {
type: "allowSecureChannelDenied";
} | {
type: "taskError";
error: UpdateFirmwareTaskError;
} | SharedTaskEvent;
/**
* The final MCU version that is retrieved from the API has the information on which bootloader it
* can be installed on. Therefore if the device is in bootloader mode, but its bootloader version
* (deviceInfo.majMin) is NOT the version for on which the MCU should be installed
* (majMin !== mcuVersion.from_bootloader_version), this means that we should first install a new
* bootloader version before installing the MCU. We return this information (isMcuUpdate as false)
* and the majMin formatted version of which bootloader should be installedb (bootloaderVersion).
* Otherwise, if the current majMin version is indeed the bootloader version on which this MCU can
* be installed, it means that we can directly install the MCU (isMcuUpdate as true)
* @param deviceMajMin the current majMin version present in the device
* @param mcuFromBootloaderVersion the bootloader on which the MCU is able to be installed
* @returns the formatted bootloader version to be installed and if it's actually needed
*/
export declare function getFlashMcuOrBootloaderDetails(deviceMajMin: string, mcuFromBootloaderVersion: string): {
bootloaderVersion: string;
isMcuUpdate: boolean;
};
export declare const updateFirmwareTask: (args: UpdateFirmwareTaskArgs) => Observable<SharedTaskEvent | {
type: "installingOsu";
progress: number;
} | {
type: "flashingMcu";
progress: number;
} | {
type: "flashingBootloader";
progress: number;
} | {
type: "firmwareUpdateCompleted";
updatedDeviceInfo: DeviceInfo;
} | {
type: "installOsuDevicePermissionRequested";
} | {
type: "installOsuDevicePermissionGranted";
} | {
type: "installOsuDevicePermissionDenied";
} | {
type: "allowSecureChannelRequested";
} | {
type: "allowSecureChannelDenied";
} | {
type: "taskError";
error: UpdateFirmwareTaskError;
}>;
//# sourceMappingURL=updateFirmware.d.ts.map