@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
31 lines • 1.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.quitApp = quitApp;
const rxjs_1 = require("rxjs");
const getAppAndVersion_1 = require("./getAppAndVersion");
const operators_1 = require("rxjs/operators");
const isDashboardName_1 = require("../../hw/isDashboardName");
/**
* Force the device to quit the currently opened app.
*
* If the device is already on the dashboard it does nothing and returns 9000.
*
* On firmware without 0x5515 (no locked device response):
* If the device is locked, it will return 0x9000.
* If the device is locked, and an app is opened, it will also return 9000 and the app will be closed when unlocked.
*
* On firmware with 0x5515 (locked device response):
* If the device is locked, it will return 0x5515.
* If the device is locked, and an app is opened, it will return 0x5515 and the app will **not** be closed when unlocked.
*
* @param transport a Transport instance
*/
function quitApp(transport) {
return (0, rxjs_1.from)((0, getAppAndVersion_1.getAppAndVersion)(transport)).pipe((0, operators_1.switchMap)(async (result) => {
if ((0, isDashboardName_1.isDashboardName)(result.appAndVersion.name)) {
return;
}
await transport.send(0xb0, 0xa7, 0x00, 0x00);
}));
}
//# sourceMappingURL=quitApp.js.map