@ledgerhq/live-cli 24.10.3-nightly.4 → 24.11.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli.js +63 -33
- package/lib/cli.js.map +1 -1
- package/lib/commands/blockchain/bot.js +7 -7
- package/lib/commands/blockchain/bot.js.map +1 -1
- package/lib/commands/blockchain/botPortfolio.js +26 -22
- package/lib/commands/blockchain/botPortfolio.js.map +1 -1
- package/lib/commands/blockchain/botTransfer.js +392 -219
- package/lib/commands/blockchain/botTransfer.js.map +1 -1
- package/lib/commands/blockchain/broadcast.js +42 -11
- package/lib/commands/blockchain/broadcast.js.map +1 -1
- package/lib/commands/blockchain/confirmOp.js +52 -12
- package/lib/commands/blockchain/confirmOp.js.map +1 -1
- package/lib/commands/blockchain/derivation.js +33 -31
- package/lib/commands/blockchain/derivation.js.map +1 -1
- package/lib/commands/blockchain/estimateMaxSpendable.js +56 -27
- package/lib/commands/blockchain/estimateMaxSpendable.js.map +1 -1
- package/lib/commands/blockchain/generateTestScanAccounts.js +37 -29
- package/lib/commands/blockchain/generateTestScanAccounts.js.map +1 -1
- package/lib/commands/blockchain/generateTestTransaction.js +96 -70
- package/lib/commands/blockchain/generateTestTransaction.js.map +1 -1
- package/lib/commands/blockchain/getAddress.js +24 -20
- package/lib/commands/blockchain/getAddress.js.map +1 -1
- package/lib/commands/blockchain/getTransactionStatus.js +69 -31
- package/lib/commands/blockchain/getTransactionStatus.js.map +1 -1
- package/lib/commands/blockchain/receive.js +42 -14
- package/lib/commands/blockchain/receive.js.map +1 -1
- package/lib/commands/blockchain/satstack.js +33 -30
- package/lib/commands/blockchain/satstack.js.map +1 -1
- package/lib/commands/blockchain/satstackStatus.js +5 -4
- package/lib/commands/blockchain/satstackStatus.js.map +1 -1
- package/lib/commands/blockchain/scanDescriptors.js +14 -8
- package/lib/commands/blockchain/scanDescriptors.js.map +1 -1
- package/lib/commands/blockchain/send.js +90 -61
- package/lib/commands/blockchain/send.js.map +1 -1
- package/lib/commands/blockchain/signMessage.d.ts +1 -1
- package/lib/commands/blockchain/signMessage.js +40 -15
- package/lib/commands/blockchain/signMessage.js.map +1 -1
- package/lib/commands/blockchain/sync.js +120 -27
- package/lib/commands/blockchain/sync.js.map +1 -1
- package/lib/commands/blockchain/testDetectOpCollision.js +48 -15
- package/lib/commands/blockchain/testDetectOpCollision.js.map +1 -1
- package/lib/commands/blockchain/testGetTrustedInputFromTxHash.js +86 -37
- package/lib/commands/blockchain/testGetTrustedInputFromTxHash.js.map +1 -1
- package/lib/commands/device/app.js +76 -42
- package/lib/commands/device/app.js.map +1 -1
- package/lib/commands/device/appUninstallAll.d.ts +1 -1
- package/lib/commands/device/appUninstallAll.js +29 -22
- package/lib/commands/device/appUninstallAll.js.map +1 -1
- package/lib/commands/device/appsCheckAllAppVersions.js +361 -208
- package/lib/commands/device/appsCheckAllAppVersions.js.map +1 -1
- package/lib/commands/device/appsInstallAll.js +24 -15
- package/lib/commands/device/appsInstallAll.js.map +1 -1
- package/lib/commands/device/appsUpdateTestAll.js +80 -69
- package/lib/commands/device/appsUpdateTestAll.js.map +1 -1
- package/lib/commands/device/cleanSpeculos.js +4 -4
- package/lib/commands/device/cleanSpeculos.js.map +1 -1
- package/lib/commands/device/customLockScreenFetch.js +84 -37
- package/lib/commands/device/customLockScreenFetch.js.map +1 -1
- package/lib/commands/device/customLockScreenFetchAndRestore.js +110 -46
- package/lib/commands/device/customLockScreenFetchAndRestore.js.map +1 -1
- package/lib/commands/device/customLockScreenFetchHash.js +7 -5
- package/lib/commands/device/customLockScreenFetchHash.js.map +1 -1
- package/lib/commands/device/customLockScreenLoad.js +72 -25
- package/lib/commands/device/customLockScreenLoad.js.map +1 -1
- package/lib/commands/device/customLockScreenRemove.js +7 -5
- package/lib/commands/device/customLockScreenRemove.js.map +1 -1
- package/lib/commands/device/devDeviceAppsScenario.js +65 -33
- package/lib/commands/device/devDeviceAppsScenario.js.map +1 -1
- package/lib/commands/device/deviceAppVersion.js +8 -5
- package/lib/commands/device/deviceAppVersion.js.map +1 -1
- package/lib/commands/device/deviceInfo.js +8 -5
- package/lib/commands/device/deviceInfo.js.map +1 -1
- package/lib/commands/device/deviceSDKFirmwareUpdate.js +68 -22
- package/lib/commands/device/deviceSDKFirmwareUpdate.js.map +1 -1
- package/lib/commands/device/deviceSDKGetBatteryStatuses.js +8 -7
- package/lib/commands/device/deviceSDKGetBatteryStatuses.js.map +1 -1
- package/lib/commands/device/deviceSDKGetDeviceInfo.js +7 -6
- package/lib/commands/device/deviceSDKGetDeviceInfo.js.map +1 -1
- package/lib/commands/device/deviceSDKToggleOnboardingEarlyCheck.js +9 -8
- package/lib/commands/device/deviceSDKToggleOnboardingEarlyCheck.js.map +1 -1
- package/lib/commands/device/deviceVersion.js +8 -5
- package/lib/commands/device/deviceVersion.js.map +1 -1
- package/lib/commands/device/discoverDevices.js +50 -15
- package/lib/commands/device/discoverDevices.js.map +1 -1
- package/lib/commands/device/firmwareRepair.js +6 -3
- package/lib/commands/device/firmwareRepair.js.map +1 -1
- package/lib/commands/device/firmwareUpdate.js +123 -63
- package/lib/commands/device/firmwareUpdate.js.map +1 -1
- package/lib/commands/device/genuineCheck.js +12 -7
- package/lib/commands/device/genuineCheck.js.map +1 -1
- package/lib/commands/device/getBatteryStatus.js +9 -5
- package/lib/commands/device/getBatteryStatus.js.map +1 -1
- package/lib/commands/device/getDeviceRunningMode.js +10 -7
- package/lib/commands/device/getDeviceRunningMode.js.map +1 -1
- package/lib/commands/device/i18n.js +79 -27
- package/lib/commands/device/i18n.js.map +1 -1
- package/lib/commands/device/listApps.d.ts +1 -1
- package/lib/commands/device/listApps.js +12 -7
- package/lib/commands/device/listApps.js.map +1 -1
- package/lib/commands/device/managerListApps.js +28 -21
- package/lib/commands/device/managerListApps.js.map +1 -1
- package/lib/commands/device/proxy.js +350 -242
- package/lib/commands/device/proxy.js.map +1 -1
- package/lib/commands/device/reinstallConfigurationConsent.js +126 -36
- package/lib/commands/device/reinstallConfigurationConsent.js.map +1 -1
- package/lib/commands/device/repl.js +10 -5
- package/lib/commands/device/repl.js.map +1 -1
- package/lib/commands/device/speculosList.js +58 -12
- package/lib/commands/device/speculosList.js.map +1 -1
- package/lib/commands/live/balanceHistory.js +79 -44
- package/lib/commands/live/balanceHistory.js.map +1 -1
- package/lib/commands/live/countervalues.js +207 -111
- package/lib/commands/live/countervalues.js.map +1 -1
- package/lib/commands/live/envs.js +6 -4
- package/lib/commands/live/envs.js.map +1 -1
- package/lib/commands/live/exportAccounts.js +56 -30
- package/lib/commands/live/exportAccounts.js.map +1 -1
- package/lib/commands/live/ledgerKeyRingProtocol.d.ts +1 -1
- package/lib/commands/live/ledgerKeyRingProtocol.js +103 -63
- package/lib/commands/live/ledgerKeyRingProtocol.js.map +1 -1
- package/lib/commands/live/ledgerSync.js +60 -20
- package/lib/commands/live/ledgerSync.js.map +1 -1
- package/lib/commands/live/liveData.js +60 -34
- package/lib/commands/live/liveData.js.map +1 -1
- package/lib/commands/live/portfolio.js +98 -68
- package/lib/commands/live/portfolio.js.map +1 -1
- package/lib/commands/live/synchronousOnboarding.js +9 -6
- package/lib/commands/live/synchronousOnboarding.js.map +1 -1
- package/lib/commands/live/user.js +4 -4
- package/lib/commands/live/user.js.map +1 -1
- package/lib/commands/live/version.js +4 -2
- package/lib/commands/live/version.js.map +1 -1
- package/lib/commands/ptx/swap.js +282 -194
- package/lib/commands/ptx/swap.js.map +1 -1
- package/lib/commands-index.d.ts +9 -9
- package/lib/commands-index.js +64 -64
- package/lib/commands-index.js.map +1 -1
- package/lib/live-common-setup-base.js +48 -26
- package/lib/live-common-setup-base.js.map +1 -1
- package/lib/live-common-setup.js +123 -66
- package/lib/live-common-setup.js.map +1 -1
- package/lib/qr.js +10 -6
- package/lib/qr.js.map +1 -1
- package/lib/scan.js +92 -84
- package/lib/scan.js.map +1 -1
- package/lib/signedOperation.js +6 -6
- package/lib/signedOperation.js.map +1 -1
- package/lib/stream.js +68 -57
- package/lib/stream.js.map +1 -1
- package/lib/transaction.js +142 -60
- package/lib/transaction.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,60 +1,132 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
54
|
+
var __values = (this && this.__values) || function(o) {
|
|
55
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
56
|
+
if (m) return m.call(o);
|
|
57
|
+
if (o && typeof o.length === "number") return {
|
|
58
|
+
next: function () {
|
|
59
|
+
if (o && i >= o.length) o = void 0;
|
|
60
|
+
return { value: o && o[i++], done: !o };
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
64
|
+
};
|
|
65
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
+
if (ar || !(i in from)) {
|
|
68
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
+
ar[i] = from[i];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
+
};
|
|
2
74
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
75
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
76
|
};
|
|
5
77
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
78
|
/* eslint-disable no-console */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
file
|
|
27
|
-
constructor(file) {
|
|
79
|
+
var invariant_1 = __importDefault(require("invariant"));
|
|
80
|
+
var fs_1 = __importDefault(require("fs"));
|
|
81
|
+
var rxjs_1 = require("rxjs");
|
|
82
|
+
var operators_1 = require("rxjs/operators");
|
|
83
|
+
var deviceAccess_1 = require("@ledgerhq/live-common/hw/deviceAccess");
|
|
84
|
+
var getDeviceInfo_1 = __importDefault(require("@ledgerhq/live-common/hw/getDeviceInfo"));
|
|
85
|
+
var api_1 = __importDefault(require("@ledgerhq/live-common/manager/api"));
|
|
86
|
+
var network_1 = __importDefault(require("@ledgerhq/live-network/network"));
|
|
87
|
+
var installApp_1 = __importDefault(require("@ledgerhq/live-common/hw/installApp"));
|
|
88
|
+
var uninstallApp_1 = __importDefault(require("@ledgerhq/live-common/hw/uninstallApp"));
|
|
89
|
+
var index_1 = require("@ledgerhq/live-common/apps/index");
|
|
90
|
+
var listAppsUseCase_1 = require("@ledgerhq/live-common/device/use-cases/listAppsUseCase");
|
|
91
|
+
var execWithTransport_1 = require("@ledgerhq/live-common/device/use-cases/execWithTransport");
|
|
92
|
+
var promise_1 = require("@ledgerhq/live-common/promise");
|
|
93
|
+
var live_env_1 = require("@ledgerhq/live-env");
|
|
94
|
+
var polyfill_1 = require("@ledgerhq/live-common/apps/polyfill");
|
|
95
|
+
var scan_1 = require("../../scan");
|
|
96
|
+
var blacklistApps = ["Fido U2F", "Security Key"];
|
|
97
|
+
var MemoFile = /** @class */ (function () {
|
|
98
|
+
function MemoFile(file) {
|
|
28
99
|
this.file = file;
|
|
29
100
|
}
|
|
30
|
-
readResults() {
|
|
31
|
-
|
|
32
|
-
|
|
101
|
+
MemoFile.prototype.readResults = function () {
|
|
102
|
+
var _this = this;
|
|
103
|
+
return new Promise(function (resolve, reject) {
|
|
104
|
+
fs_1.default.readFile(_this.file, "utf8", function (err, data) {
|
|
33
105
|
if (err)
|
|
34
106
|
return reject(err);
|
|
35
107
|
resolve(data
|
|
36
108
|
.split("\n")
|
|
37
|
-
.map((line)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
109
|
+
.map(function (line) {
|
|
110
|
+
var _a = __read(line.split(":").map(function (s) { return s.trim(); })), versionIdStr = _a[0], appPath = _a[1], status = _a[2], rest = _a.slice(3);
|
|
111
|
+
var error = rest.join(": ");
|
|
112
|
+
var versionId = parseInt(versionIdStr, 10);
|
|
41
113
|
if (isNaN(versionId) || !isFinite(versionId) || versionId <= 0) {
|
|
42
114
|
return;
|
|
43
115
|
}
|
|
44
116
|
if (versionId && appPath) {
|
|
45
117
|
if (status === "OK") {
|
|
46
118
|
return {
|
|
47
|
-
versionId,
|
|
48
|
-
appPath,
|
|
119
|
+
versionId: versionId,
|
|
120
|
+
appPath: appPath,
|
|
49
121
|
status: "OK",
|
|
50
122
|
};
|
|
51
123
|
}
|
|
52
124
|
else if (status === "KO" && typeof error === "string") {
|
|
53
125
|
return {
|
|
54
|
-
versionId,
|
|
55
|
-
appPath,
|
|
126
|
+
versionId: versionId,
|
|
127
|
+
appPath: appPath,
|
|
56
128
|
status: "KO",
|
|
57
|
-
error,
|
|
129
|
+
error: error,
|
|
58
130
|
};
|
|
59
131
|
}
|
|
60
132
|
}
|
|
@@ -62,98 +134,148 @@ class MemoFile {
|
|
|
62
134
|
.filter(Boolean));
|
|
63
135
|
});
|
|
64
136
|
});
|
|
65
|
-
}
|
|
66
|
-
writeResults(results) {
|
|
67
|
-
|
|
137
|
+
};
|
|
138
|
+
MemoFile.prototype.writeResults = function (results) {
|
|
139
|
+
var _this = this;
|
|
140
|
+
var data = results
|
|
68
141
|
.slice(0)
|
|
69
|
-
.sort((a, b)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
result
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
142
|
+
.sort(function (a, b) {
|
|
143
|
+
return 1000000 * a.status.localeCompare(b.status) +
|
|
144
|
+
100000 * a.appPath.localeCompare(b.appPath) +
|
|
145
|
+
(a.versionId - b.versionId);
|
|
146
|
+
})
|
|
147
|
+
.map(function (result) {
|
|
148
|
+
return [
|
|
149
|
+
result.versionId,
|
|
150
|
+
result.appPath,
|
|
151
|
+
result.status,
|
|
152
|
+
result.status === "KO" ? result.error : "",
|
|
153
|
+
].join(": ");
|
|
154
|
+
})
|
|
78
155
|
.join("\n");
|
|
79
|
-
return new Promise((resolve, reject)
|
|
80
|
-
fs_1.default.writeFile(
|
|
156
|
+
return new Promise(function (resolve, reject) {
|
|
157
|
+
fs_1.default.writeFile(_this.file, data, "utf8", function (err) {
|
|
81
158
|
if (err)
|
|
82
159
|
reject(err);
|
|
83
160
|
else
|
|
84
161
|
resolve();
|
|
85
162
|
});
|
|
86
163
|
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
164
|
+
};
|
|
165
|
+
return MemoFile;
|
|
166
|
+
}());
|
|
167
|
+
var results = [];
|
|
168
|
+
var memoFile;
|
|
169
|
+
var getAPIDeviceVersionIds = function (deviceInfo) { return __awaiter(void 0, void 0, void 0, function () {
|
|
170
|
+
var targetId, data, all, data_1, data_1_1, device, _a, _b, deviceVersion;
|
|
171
|
+
var e_1, _c, e_2, _d;
|
|
172
|
+
return __generator(this, function (_e) {
|
|
173
|
+
switch (_e.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
targetId = String(deviceInfo.targetId);
|
|
176
|
+
return [4 /*yield*/, (0, network_1.default)({
|
|
177
|
+
method: "GET",
|
|
178
|
+
url: "".concat((0, live_env_1.getEnv)("MANAGER_API_BASE"), "/devices"),
|
|
179
|
+
})];
|
|
180
|
+
case 1:
|
|
181
|
+
data = (_e.sent()).data;
|
|
182
|
+
all = [];
|
|
183
|
+
try {
|
|
184
|
+
for (data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
|
|
185
|
+
device = data_1_1.value;
|
|
186
|
+
try {
|
|
187
|
+
for (_a = (e_2 = void 0, __values(device.device_versions)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
188
|
+
deviceVersion = _b.value;
|
|
189
|
+
if (deviceVersion.target_id === targetId) {
|
|
190
|
+
all.push(deviceVersion.id);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
195
|
+
finally {
|
|
196
|
+
try {
|
|
197
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
198
|
+
}
|
|
199
|
+
finally { if (e_2) throw e_2.error; }
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
204
|
+
finally {
|
|
205
|
+
try {
|
|
206
|
+
if (data_1_1 && !data_1_1.done && (_c = data_1.return)) _c.call(data_1);
|
|
207
|
+
}
|
|
208
|
+
finally { if (e_1) throw e_1.error; }
|
|
209
|
+
}
|
|
210
|
+
return [2 /*return*/, all];
|
|
103
211
|
}
|
|
104
|
-
}
|
|
105
|
-
|
|
212
|
+
});
|
|
213
|
+
}); };
|
|
214
|
+
var compatibleAppVersion = function (v, deviceVersionIds, deviceModel, deviceInfo) {
|
|
215
|
+
return v.providers.includes(1) &&
|
|
216
|
+
deviceVersionIds.some(function (id) { return v.device_versions.includes(id); }) && // heuristic to see if app is compatible...
|
|
217
|
+
v.firmware.startsWith(deviceModel.id.toLowerCase() + "/" + deviceInfo.version);
|
|
106
218
|
};
|
|
107
|
-
|
|
108
|
-
deviceVersionIds
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
219
|
+
var findCandidates = function (deviceModel, applications, deviceInfo) { return __awaiter(void 0, void 0, void 0, function () {
|
|
220
|
+
var deviceVersionIds, candidates;
|
|
221
|
+
return __generator(this, function (_a) {
|
|
222
|
+
switch (_a.label) {
|
|
223
|
+
case 0:
|
|
224
|
+
console.log(deviceInfo);
|
|
225
|
+
return [4 /*yield*/, getAPIDeviceVersionIds(deviceInfo)];
|
|
226
|
+
case 1:
|
|
227
|
+
deviceVersionIds = _a.sent();
|
|
228
|
+
if (!deviceVersionIds.length)
|
|
229
|
+
throw new Error("unknown device version plugged");
|
|
230
|
+
candidates = applications
|
|
231
|
+
.filter(function (a) { return !blacklistApps.includes(a.name); })
|
|
232
|
+
.flatMap(function (app) {
|
|
233
|
+
var deps = (0, polyfill_1.getDependencies)(app.name);
|
|
234
|
+
return app.application_versions
|
|
235
|
+
.filter(function (v) { return compatibleAppVersion(v, deviceVersionIds, deviceModel, deviceInfo); })
|
|
236
|
+
.map(function (version) {
|
|
237
|
+
return {
|
|
238
|
+
app: app,
|
|
239
|
+
version: version,
|
|
240
|
+
installQueue: __spreadArray(__spreadArray([], __read(deps
|
|
241
|
+
.map(function (name) {
|
|
242
|
+
var depApp = applications.find(function (a) { return a.name === name; });
|
|
243
|
+
return depApp
|
|
244
|
+
? depApp.application_versions.find(function (v) {
|
|
245
|
+
return compatibleAppVersion(v, deviceVersionIds, deviceModel, deviceInfo) &&
|
|
246
|
+
v.version === version.version;
|
|
247
|
+
})
|
|
248
|
+
: null;
|
|
249
|
+
})
|
|
250
|
+
.filter(Boolean)), false), [
|
|
251
|
+
version,
|
|
252
|
+
], false),
|
|
253
|
+
};
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
if (process.env.RANDOM_APPS_ORDER) {
|
|
257
|
+
candidates.sort(function () { return Math.random() - 0.5; });
|
|
258
|
+
}
|
|
259
|
+
return [2 /*return*/, candidates];
|
|
260
|
+
}
|
|
139
261
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
262
|
+
}); };
|
|
263
|
+
var installCandidate = function (t, deviceInfo, candidate) {
|
|
264
|
+
return rxjs_1.concat.apply(void 0, __spreadArray([], __read(candidate.installQueue.flatMap(function (app) { return [
|
|
265
|
+
(0, rxjs_1.defer)(function () { return (0, promise_1.delay)((0, live_env_1.getEnv)("MANAGER_INSTALL_DELAY")); }),
|
|
266
|
+
(0, rxjs_1.defer)(function () { return (0, installApp_1.default)(t, deviceInfo.targetId, app); }),
|
|
267
|
+
]; })), false));
|
|
268
|
+
};
|
|
269
|
+
var uninstallCandidate = function (t, deviceInfo, candidate) {
|
|
270
|
+
return rxjs_1.concat.apply(void 0, __spreadArray([], __read(candidate.installQueue
|
|
271
|
+
.slice(0)
|
|
272
|
+
.reverse()
|
|
273
|
+
.flatMap(function (app) { return [
|
|
274
|
+
(0, rxjs_1.defer)(function () { return (0, promise_1.delay)((0, live_env_1.getEnv)("MANAGER_INSTALL_DELAY")); }),
|
|
275
|
+
(0, rxjs_1.defer)(function () { return (0, uninstallApp_1.default)(t, deviceInfo.targetId, app); }),
|
|
276
|
+
]; })), false));
|
|
144
277
|
};
|
|
145
|
-
|
|
146
|
-
(0, rxjs_1.defer)(() => (0, promise_1.delay)((0, live_env_1.getEnv)("MANAGER_INSTALL_DELAY"))),
|
|
147
|
-
(0, rxjs_1.defer)(() => (0, installApp_1.default)(t, deviceInfo.targetId, app)),
|
|
148
|
-
]));
|
|
149
|
-
const uninstallCandidate = (t, deviceInfo, candidate) => (0, rxjs_1.concat)(...candidate.installQueue
|
|
150
|
-
.slice(0)
|
|
151
|
-
.reverse()
|
|
152
|
-
.flatMap(app => [
|
|
153
|
-
(0, rxjs_1.defer)(() => (0, promise_1.delay)((0, live_env_1.getEnv)("MANAGER_INSTALL_DELAY"))),
|
|
154
|
-
(0, rxjs_1.defer)(() => (0, uninstallApp_1.default)(t, deviceInfo.targetId, app)),
|
|
155
|
-
]));
|
|
156
|
-
const getCandidateName = (candidate) => {
|
|
278
|
+
var getCandidateName = function (candidate) {
|
|
157
279
|
return (candidate.version.name +
|
|
158
280
|
" " +
|
|
159
281
|
candidate.version.version +
|
|
@@ -161,14 +283,14 @@ const getCandidateName = (candidate) => {
|
|
|
161
283
|
candidate.version.firmware +
|
|
162
284
|
")");
|
|
163
285
|
};
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
286
|
+
var lastResult;
|
|
287
|
+
var checkInstalled = function (installed, candidate) {
|
|
288
|
+
var name = getCandidateName(candidate);
|
|
289
|
+
var ins = installed.find(function (i) { return i.name === candidate.version.name || i.hash === candidate.version.hash; });
|
|
290
|
+
var result;
|
|
169
291
|
if (!ins) {
|
|
170
292
|
if (installed.length > 0) {
|
|
171
|
-
|
|
293
|
+
var message = " list apps don't find installed app? Found these: " + JSON.stringify(installed);
|
|
172
294
|
result = {
|
|
173
295
|
versionId: candidate.version.id,
|
|
174
296
|
appPath: candidate.version.firmware,
|
|
@@ -186,8 +308,8 @@ const checkInstalled = (installed, candidate) => {
|
|
|
186
308
|
}
|
|
187
309
|
}
|
|
188
310
|
else {
|
|
189
|
-
|
|
190
|
-
|
|
311
|
+
var hashMatches = ins.hash === candidate.version.hash;
|
|
312
|
+
var hasBytes = !!candidate.version.bytes;
|
|
191
313
|
if (hashMatches && hasBytes) {
|
|
192
314
|
result = {
|
|
193
315
|
versionId: candidate.version.id,
|
|
@@ -197,7 +319,7 @@ const checkInstalled = (installed, candidate) => {
|
|
|
197
319
|
console.log("OK " + name);
|
|
198
320
|
}
|
|
199
321
|
else {
|
|
200
|
-
|
|
322
|
+
var message = (hashMatches
|
|
201
323
|
? ""
|
|
202
324
|
: " have BAD HASH. API have " + candidate.version.hash + " but device have " + ins.hash) +
|
|
203
325
|
(hasBytes ? "" : " DOES NOT have bytes defined!");
|
|
@@ -210,23 +332,25 @@ const checkInstalled = (installed, candidate) => {
|
|
|
210
332
|
console.error("FAIL " + name + message);
|
|
211
333
|
}
|
|
212
334
|
}
|
|
213
|
-
results = results.filter(r
|
|
335
|
+
results = results.filter(function (r) { return r.versionId !== result.versionId; }).concat(result);
|
|
214
336
|
if (memoFile) {
|
|
215
337
|
return (0, rxjs_1.from)(memoFile.writeResults(results)).pipe((0, operators_1.ignoreElements)());
|
|
216
338
|
}
|
|
217
339
|
return rxjs_1.EMPTY;
|
|
218
340
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
341
|
+
var wipeAll = function (t, deviceInfo) {
|
|
342
|
+
return (0, listAppsUseCase_1.listAppsUseCase)(t, deviceInfo).pipe((0, operators_1.filter)(function (e) { return e.type === "result"; }), (0, operators_1.map)(function (e) { return e.result; }), (0, operators_1.mergeMap)(function (listAppsResult) {
|
|
343
|
+
var exec = (0, execWithTransport_1.execWithTransport)(t);
|
|
344
|
+
var s = (0, index_1.initState)(listAppsResult);
|
|
345
|
+
s = (0, index_1.reducer)(s, {
|
|
346
|
+
type: "wipe",
|
|
347
|
+
});
|
|
348
|
+
if (s.uninstallQueue.length) {
|
|
349
|
+
console.log("Uninstall " + s.uninstallQueue.length + " app(s)");
|
|
350
|
+
}
|
|
351
|
+
return (0, index_1.runAll)(s, exec);
|
|
352
|
+
}));
|
|
353
|
+
};
|
|
230
354
|
exports.default = {
|
|
231
355
|
description: "install/uninstall all possible apps available on our API to check all is good (even old app versions)",
|
|
232
356
|
args: [
|
|
@@ -237,81 +361,110 @@ exports.default = {
|
|
|
237
361
|
desc: "a file to memorize the previously saved result so we don't run again from the start",
|
|
238
362
|
},
|
|
239
363
|
],
|
|
240
|
-
job:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
(0,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
364
|
+
job: function (_a) {
|
|
365
|
+
var device = _a.device, memo = _a.memo;
|
|
366
|
+
return (0, deviceAccess_1.withDevice)(device || "")(function (t) {
|
|
367
|
+
return (0, rxjs_1.from)(Promise.all([(0, getDeviceInfo_1.default)(t), api_1.default.listApps()]).then(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
368
|
+
var deviceModel, candidates, candidatesErrors, candidatesNew, all;
|
|
369
|
+
var _c = __read(_b, 2), deviceInfo = _c[0], applications = _c[1];
|
|
370
|
+
return __generator(this, function (_d) {
|
|
371
|
+
switch (_d.label) {
|
|
372
|
+
case 0:
|
|
373
|
+
deviceModel = t.deviceModel;
|
|
374
|
+
(0, invariant_1.default)(deviceModel, "device model mandatory");
|
|
375
|
+
return [4 /*yield*/, findCandidates(deviceModel, applications, deviceInfo)];
|
|
376
|
+
case 1:
|
|
377
|
+
candidates = _d.sent();
|
|
378
|
+
candidatesErrors = [];
|
|
379
|
+
candidatesNew = __spreadArray([], __read(candidates), false);
|
|
380
|
+
if (!memo) return [3 /*break*/, 3];
|
|
381
|
+
memoFile = new MemoFile(memo);
|
|
382
|
+
return [4 /*yield*/, memoFile.readResults()];
|
|
383
|
+
case 2:
|
|
384
|
+
results = _d.sent();
|
|
385
|
+
candidatesErrors = [];
|
|
386
|
+
candidatesNew = [];
|
|
387
|
+
candidates.forEach(function (c) {
|
|
388
|
+
var result = results.find(function (r) { return r.versionId === c.version.id; });
|
|
389
|
+
if (process.env.VERBOSE_CANDIDATE) {
|
|
390
|
+
console.log(c.version.id, c.version.firmware, result
|
|
391
|
+
? "result was " +
|
|
392
|
+
result.status +
|
|
393
|
+
(result.status === "KO" ? " " + result.error : "")
|
|
394
|
+
: "");
|
|
395
|
+
}
|
|
396
|
+
if (result) {
|
|
397
|
+
if (result.status === "KO") {
|
|
398
|
+
candidatesErrors.push(c);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
candidatesNew.push(c);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
_d.label = 3;
|
|
406
|
+
case 3:
|
|
407
|
+
all = __spreadArray(__spreadArray([], __read(candidatesNew), false), __read(candidatesErrors), false);
|
|
408
|
+
if (candidates.length) {
|
|
409
|
+
console.log(((100 * (candidates.length - candidatesNew.length)) / candidates.length).toFixed(0) +
|
|
410
|
+
"% of apps versions tested. (" +
|
|
411
|
+
candidates.length +
|
|
412
|
+
" in total. " +
|
|
413
|
+
candidatesNew.length +
|
|
414
|
+
" new. " +
|
|
415
|
+
candidatesErrors.length +
|
|
416
|
+
" errors)");
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
console.log("No apps candidate found");
|
|
420
|
+
}
|
|
421
|
+
return [2 /*return*/, [deviceInfo, all]];
|
|
268
422
|
}
|
|
269
423
|
});
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}),
|
|
424
|
+
}); })).pipe((0, operators_1.mergeMap)(function (_a) {
|
|
425
|
+
var _b = __read(_a, 2), deviceInfo = _b[0], candidates = _b[1];
|
|
426
|
+
return (0, rxjs_1.concat)(wipeAll(t, deviceInfo).pipe((0, operators_1.ignoreElements)()), (0, rxjs_1.of)([deviceInfo, candidates]));
|
|
427
|
+
}), (0, operators_1.mergeMap)(function (_a) {
|
|
428
|
+
var _b = __read(_a, 2), deviceInfo = _b[0], candidates = _b[1];
|
|
429
|
+
return candidates.reduce(function (acc, candidate) {
|
|
430
|
+
return (0, rxjs_1.concat)(acc, (0, rxjs_1.defer)(function () {
|
|
431
|
+
return installCandidate(t, deviceInfo, candidate).pipe((0, operators_1.ignoreElements)(), (0, operators_1.catchError)(function (e) {
|
|
432
|
+
var result = {
|
|
433
|
+
versionId: candidate.version.id,
|
|
434
|
+
appPath: candidate.version.firmware,
|
|
435
|
+
status: "KO",
|
|
436
|
+
error: "FAILED installing, got " + String(e.message),
|
|
437
|
+
};
|
|
438
|
+
lastResult = result;
|
|
439
|
+
results = results
|
|
440
|
+
.filter(function (r) { return r.versionId !== result.versionId; })
|
|
441
|
+
.concat(result);
|
|
442
|
+
console.error("FAILED installing " + getCandidateName(candidate), e);
|
|
443
|
+
if (memoFile) {
|
|
444
|
+
return (0, rxjs_1.from)(memoFile.writeResults(results)).pipe((0, operators_1.ignoreElements)());
|
|
445
|
+
}
|
|
446
|
+
return rxjs_1.EMPTY;
|
|
447
|
+
}));
|
|
448
|
+
}), (0, rxjs_1.defer)(function () { return (0, promise_1.delay)(3000); }).pipe((0, operators_1.ignoreElements)()), (0, rxjs_1.defer)(function () {
|
|
449
|
+
return (0, rxjs_1.from)(new Promise(function (resolve, reject) {
|
|
450
|
+
api_1.default.listInstalledApps(t, {
|
|
451
|
+
targetId: deviceInfo.targetId,
|
|
452
|
+
perso: "perso_11",
|
|
453
|
+
}).subscribe({
|
|
454
|
+
next: function (e) {
|
|
455
|
+
if (e.type === "result") {
|
|
456
|
+
resolve(e.payload);
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
error: reject,
|
|
460
|
+
});
|
|
461
|
+
})).pipe((0, operators_1.mergeMap)(function (installed) {
|
|
462
|
+
return (0, rxjs_1.concat)(checkInstalled(installed, candidate), uninstallCandidate(t, deviceInfo, candidate)).pipe((0, operators_1.ignoreElements)());
|
|
463
|
+
}));
|
|
464
|
+
}));
|
|
465
|
+
}, rxjs_1.EMPTY);
|
|
466
|
+
}));
|
|
467
|
+
});
|
|
468
|
+
},
|
|
316
469
|
};
|
|
317
470
|
//# sourceMappingURL=appsCheckAllAppVersions.js.map
|