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