UNPKG

@ledgerhq/live-common

Version:
30 lines 1.71 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.execWithTransport = void 0; const installApp_1 = __importDefault(require("../../hw/installApp")); const installAppWithRestore_1 = __importDefault(require("../../hw/installAppWithRestore")); const uninstallApp_1 = __importDefault(require("../../hw/uninstallApp")); const uninstallAppWithBackup_1 = __importDefault(require("../../hw/uninstallAppWithBackup")); /** * ExecWithTransport * @param transport - The transport object used to communicate with the Ledger device. * @param appsBackupEnabled - Whether apps backup is enabled (feature flagged) * @returns An observable that emits the progress of the execution. */ const execWithTransport = (transport, appsBackupEnabled = false) => args => { const { appOp, targetId, app, modelId, storage, skipAppDataBackup } = args; // if appsBackupEnabled is true, we will use the data backup/restore flow // modelId & storage are required for the new flow, but can still be // undefined for the old flow, so we need to check if they are defined if (appsBackupEnabled && modelId && storage) { const fn = appOp.type === "install" ? installAppWithRestore_1.default : uninstallAppWithBackup_1.default; return fn(transport, targetId, app, modelId, storage, skipAppDataBackup); } const fn = appOp.type === "install" ? installApp_1.default : uninstallApp_1.default; return fn(transport, targetId, app); }; exports.execWithTransport = execWithTransport; //# sourceMappingURL=execWithTransport.js.map