@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,10 +1,46 @@
|
|
|
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
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
39
|
+
var index_1 = require("@ledgerhq/ledger-key-ring-protocol/index");
|
|
40
|
+
var hw_ledger_key_ring_protocol_1 = require("@ledgerhq/hw-ledger-key-ring-protocol");
|
|
41
|
+
var deviceAccess_1 = require("@ledgerhq/live-common/hw/deviceAccess");
|
|
42
|
+
var live_env_1 = require("@ledgerhq/live-env");
|
|
43
|
+
var scan_1 = require("../../scan");
|
|
8
44
|
exports.default = {
|
|
9
45
|
description: "Ledger Key Ring Protocol command",
|
|
10
46
|
args: [
|
|
@@ -93,65 +129,69 @@ exports.default = {
|
|
|
93
129
|
desc: "api base url for Ledger Key Ring Protocol",
|
|
94
130
|
},
|
|
95
131
|
],
|
|
96
|
-
job:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
132
|
+
job: function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
133
|
+
var context, sdk, sdkMethod;
|
|
134
|
+
var device = _b.device, initMemberCredentials = _b.initMemberCredentials, getKeyRingTree = _b.getKeyRingTree, encryptUserData = _b.encryptUserData, decryptUserData = _b.decryptUserData, getMembers = _b.getMembers, restoreKeyRingTree = _b.restoreKeyRingTree, destroyKeyRingTree = _b.destroyKeyRingTree, pubKey = _b.pubKey, privateKey = _b.privateKey, rootId = _b.rootId, walletSyncEncryptionKey = _b.walletSyncEncryptionKey, applicationPath = _b.applicationPath, message = _b.message, _c = _b.applicationId, applicationId = _c === void 0 ? 16 : _c, _d = _b.name, name = _d === void 0 ? "CLI" : _d, _e = _b.apiBaseUrl, apiBaseUrl = _e === void 0 ? (0, live_env_1.getEnv)("TRUSTCHAIN_API_STAGING") : _e;
|
|
135
|
+
return __generator(this, function (_f) {
|
|
136
|
+
if (!applicationId)
|
|
137
|
+
return [2 /*return*/, Promise.reject("applicationId is required")];
|
|
138
|
+
if (!name)
|
|
139
|
+
return [2 /*return*/, Promise.reject("name is required")];
|
|
140
|
+
if (!apiBaseUrl)
|
|
141
|
+
return [2 /*return*/, Promise.reject("apiBaseUrl is required")];
|
|
142
|
+
context = {
|
|
143
|
+
applicationId: applicationId,
|
|
144
|
+
name: name,
|
|
145
|
+
apiBaseUrl: apiBaseUrl,
|
|
146
|
+
};
|
|
147
|
+
sdk = (0, index_1.getSdk)(false, context, deviceAccess_1.withDevice);
|
|
148
|
+
if (initMemberCredentials) {
|
|
149
|
+
return [2 /*return*/, sdk.initMemberCredentials()];
|
|
150
|
+
}
|
|
151
|
+
if (getKeyRingTree) {
|
|
152
|
+
if (!pubKey || !privateKey) {
|
|
153
|
+
return [2 /*return*/, Promise.reject("pubKey and privateKey are required")];
|
|
154
|
+
}
|
|
155
|
+
return [2 /*return*/, sdk
|
|
156
|
+
.getOrCreateTrustchain(device || "", { pubkey: pubKey, privatekey: privateKey })
|
|
157
|
+
.then(function (result) { return result.trustchain; })];
|
|
158
|
+
}
|
|
159
|
+
if (getMembers || restoreKeyRingTree || destroyKeyRingTree) {
|
|
160
|
+
if (!pubKey || !privateKey)
|
|
161
|
+
return [2 /*return*/, Promise.reject("pubKey and privateKey are required")];
|
|
162
|
+
if (!rootId)
|
|
163
|
+
return [2 /*return*/, Promise.reject("rootId is required")];
|
|
164
|
+
if (!walletSyncEncryptionKey)
|
|
165
|
+
return [2 /*return*/, Promise.reject("walletSyncEncryptionKey is required")];
|
|
166
|
+
if (!applicationPath)
|
|
167
|
+
return [2 /*return*/, Promise.reject("applicationPath is required")];
|
|
168
|
+
sdkMethod = getMembers
|
|
169
|
+
? "getMembers"
|
|
170
|
+
: restoreKeyRingTree
|
|
171
|
+
? "restoreTrustchain"
|
|
172
|
+
: "destroyTrustchain";
|
|
173
|
+
return [2 /*return*/, sdk[sdkMethod]({ rootId: rootId, walletSyncEncryptionKey: walletSyncEncryptionKey, applicationPath: applicationPath }, { pubkey: pubKey, privatekey: privateKey })];
|
|
115
174
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
: "destroyTrustchain";
|
|
134
|
-
return sdk[sdkMethod]({ rootId, walletSyncEncryptionKey, applicationPath }, { pubkey: pubKey, privatekey: privateKey });
|
|
135
|
-
}
|
|
136
|
-
if (encryptUserData || decryptUserData) {
|
|
137
|
-
if (!rootId)
|
|
138
|
-
return Promise.reject("rootId is required");
|
|
139
|
-
if (!walletSyncEncryptionKey)
|
|
140
|
-
return Promise.reject("walletSyncEncryptionKey is required");
|
|
141
|
-
if (!applicationPath)
|
|
142
|
-
return Promise.reject("applicationPath is required");
|
|
143
|
-
if (!message)
|
|
144
|
-
return Promise.reject("message is required");
|
|
145
|
-
if (encryptUserData) {
|
|
146
|
-
return sdk
|
|
147
|
-
.encryptUserData({ rootId, walletSyncEncryptionKey, applicationPath }, new TextEncoder().encode(message))
|
|
148
|
-
.then(array => Buffer.from(array).toString("hex"));
|
|
175
|
+
if (encryptUserData || decryptUserData) {
|
|
176
|
+
if (!rootId)
|
|
177
|
+
return [2 /*return*/, Promise.reject("rootId is required")];
|
|
178
|
+
if (!walletSyncEncryptionKey)
|
|
179
|
+
return [2 /*return*/, Promise.reject("walletSyncEncryptionKey is required")];
|
|
180
|
+
if (!applicationPath)
|
|
181
|
+
return [2 /*return*/, Promise.reject("applicationPath is required")];
|
|
182
|
+
if (!message)
|
|
183
|
+
return [2 /*return*/, Promise.reject("message is required")];
|
|
184
|
+
if (encryptUserData) {
|
|
185
|
+
return [2 /*return*/, sdk
|
|
186
|
+
.encryptUserData({ rootId: rootId, walletSyncEncryptionKey: walletSyncEncryptionKey, applicationPath: applicationPath }, new TextEncoder().encode(message))
|
|
187
|
+
.then(function (array) { return Buffer.from(array).toString("hex"); })];
|
|
188
|
+
}
|
|
189
|
+
return [2 /*return*/, sdk
|
|
190
|
+
.decryptUserData({ rootId: rootId, walletSyncEncryptionKey: walletSyncEncryptionKey, applicationPath: applicationPath }, hw_ledger_key_ring_protocol_1.crypto.from_hex(message))
|
|
191
|
+
.then(function (array) { return new TextDecoder().decode(array); })];
|
|
149
192
|
}
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
return Promise.reject("command does not exist");
|
|
155
|
-
},
|
|
193
|
+
return [2 /*return*/, Promise.reject("command does not exist")];
|
|
194
|
+
});
|
|
195
|
+
}); },
|
|
156
196
|
};
|
|
157
197
|
//# sourceMappingURL=ledgerKeyRingProtocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledgerKeyRingProtocol.js","sourceRoot":"","sources":["../../../src/commands/live/ledgerKeyRingProtocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ledgerKeyRingProtocol.js","sourceRoot":"","sources":["../../../src/commands/live/ledgerKeyRingProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAkE;AAClE,qFAA+D;AAC/D,sEAAmE;AACnE,+CAA4C;AAC5C,mCAAyD;AAsBzD,kBAAe;IACb,WAAW,EAAE,kCAAkC;IAC/C,IAAI,EAAE;QACJ,gBAAS;QACT;YACE,IAAI,EAAE,uBAAuB;YAC7B,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,sDAAsD;SAC7D;QACD;YACE,IAAI,EAAE,gBAAgB;YACtB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,+CAA+C;SACtD;QACD;YACE,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,wFAAwF;SAC/F;QACD;YACE,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,wFAAwF;SAC/F;QACD;YACE,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,kDAAkD;SACzD;QACD;YACE,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,yCAAyC;SAChD;QACD;YACE,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,yCAAyC;SAChD;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,sFAAsF;SAC7F;QACD;YACE,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,0FAA0F;SACjG;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,wEAAwE;S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AAC,EAA/B,CAA+B,CAAC,EAAC;YACpD,CAAC;YAED,sBAAO,OAAO,CAAC,MAAM,CAAC,wBAAwB,CAAC,EAAC;;SACjD;CACF,CAAC"}
|
|
@@ -22,12 +22,48 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
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;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
25
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
62
|
+
var index_1 = require("@ledgerhq/ledger-key-ring-protocol/index");
|
|
63
|
+
var index_2 = require("@ledgerhq/live-wallet/cloudsync/index");
|
|
64
|
+
var index_3 = __importStar(require("@ledgerhq/live-wallet/walletsync/index"));
|
|
65
|
+
var deviceAccess_1 = require("@ledgerhq/live-common/hw/deviceAccess");
|
|
66
|
+
var live_env_1 = require("@ledgerhq/live-env");
|
|
31
67
|
exports.default = {
|
|
32
68
|
description: "Ledger Sync command",
|
|
33
69
|
args: [
|
|
@@ -101,7 +137,8 @@ exports.default = {
|
|
|
101
137
|
desc: "api base url for Cloud Sync",
|
|
102
138
|
},
|
|
103
139
|
],
|
|
104
|
-
job:
|
|
140
|
+
job: function (_a) {
|
|
141
|
+
var push = _a.push, pull = _a.pull, pubKey = _a.pubKey, privateKey = _a.privateKey, rootId = _a.rootId, walletSyncEncryptionKey = _a.walletSyncEncryptionKey, applicationPath = _a.applicationPath, data = _a.data, version = _a.version, _b = _a.applicationId, applicationId = _b === void 0 ? 16 : _b, _c = _a.name, name = _c === void 0 ? "CLI" : _c, _d = _a.apiBaseUrl, apiBaseUrl = _d === void 0 ? (0, live_env_1.getEnv)("TRUSTCHAIN_API_STAGING") : _d, _e = _a.cloudSyncApiBaseUrl, cloudSyncApiBaseUrl = _e === void 0 ? (0, live_env_1.getEnv)("CLOUD_SYNC_API_STAGING") : _e;
|
|
105
142
|
if (!applicationId)
|
|
106
143
|
return "applicationId is required";
|
|
107
144
|
if (!name)
|
|
@@ -118,31 +155,34 @@ exports.default = {
|
|
|
118
155
|
return "applicationPath is required";
|
|
119
156
|
if (push && !data)
|
|
120
157
|
return "data is required";
|
|
121
|
-
|
|
122
|
-
applicationId,
|
|
123
|
-
name,
|
|
124
|
-
apiBaseUrl,
|
|
158
|
+
var context = {
|
|
159
|
+
applicationId: applicationId,
|
|
160
|
+
name: name,
|
|
161
|
+
apiBaseUrl: apiBaseUrl,
|
|
125
162
|
};
|
|
126
|
-
|
|
127
|
-
|
|
163
|
+
var ledgerKeyRingProtocolSDK = (0, index_1.getSdk)(false, context, deviceAccess_1.withDevice);
|
|
164
|
+
var cloudSyncSDK = new index_2.CloudSyncSDK({
|
|
128
165
|
apiBaseUrl: cloudSyncApiBaseUrl,
|
|
129
166
|
slug: index_3.liveSlug,
|
|
130
167
|
schema: index_3.default.schema,
|
|
131
168
|
trustchainSdk: ledgerKeyRingProtocolSDK,
|
|
132
|
-
getCurrentVersion: ()
|
|
133
|
-
saveNewUpdate:
|
|
134
|
-
|
|
135
|
-
|
|
169
|
+
getCurrentVersion: function () { return version || 1; },
|
|
170
|
+
saveNewUpdate: function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
171
|
+
return __generator(this, function (_a) {
|
|
172
|
+
console.log(event);
|
|
173
|
+
return [2 /*return*/];
|
|
174
|
+
});
|
|
175
|
+
}); },
|
|
136
176
|
});
|
|
137
177
|
if (push) {
|
|
138
178
|
return cloudSyncSDK
|
|
139
|
-
.push({ rootId, walletSyncEncryptionKey, applicationPath }, { pubkey: pubKey, privatekey: privateKey }, JSON.parse(data))
|
|
140
|
-
.then(result
|
|
179
|
+
.push({ rootId: rootId, walletSyncEncryptionKey: walletSyncEncryptionKey, applicationPath: applicationPath }, { pubkey: pubKey, privatekey: privateKey }, JSON.parse(data))
|
|
180
|
+
.then(function (result) { return JSON.stringify(result, null, 2); });
|
|
141
181
|
}
|
|
142
182
|
if (pull) {
|
|
143
183
|
return cloudSyncSDK
|
|
144
|
-
.pull({ rootId, walletSyncEncryptionKey, applicationPath }, { pubkey: pubKey, privatekey: privateKey })
|
|
145
|
-
.then(result
|
|
184
|
+
.pull({ rootId: rootId, walletSyncEncryptionKey: walletSyncEncryptionKey, applicationPath: applicationPath }, { pubkey: pubKey, privatekey: privateKey })
|
|
185
|
+
.then(function (result) { return JSON.stringify(result, null, 2); });
|
|
146
186
|
}
|
|
147
187
|
return "command does not exist";
|
|
148
188
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledgerSync.js","sourceRoot":"","sources":["../../../src/commands/live/ledgerSync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ledgerSync.js","sourceRoot":"","sources":["../../../src/commands/live/ledgerSync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAkE;AAClE,+DAAkF;AAClF,8EAGgD;AAChD,sEAAmE;AACnE,+CAA4C;AAkB5C,kBAAe;IACb,WAAW,EAAE,qBAAqB;IAClC,IAAI,EAAE;QACJ;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,sDAAsD;SAC7D;QACD;YACE,IAAI,EAAE,MAAM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,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;;;iBACpB;SACF,CAAC,CAAC;QAEH,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,YAAY;iBAChB,IAAI,CACH,EAAE,MAAM,QAAA,EAAE,uBAAuB,yBAAA,EAAE,eAAe,iBAAA,EAAE,EACpD,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,EAC1C,IAAI,CAAC,KAAK,CAAC,IAAK,CAAa,CAC9B;iBACA,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAA/B,CAA+B,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,YAAY;iBAChB,IAAI,CACH,EAAE,MAAM,QAAA,EAAE,uBAAuB,yBAAA,EAAE,eAAe,iBAAA,EAAE,EACpD,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,CAC3C;iBACA,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAA/B,CAA+B,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,wBAAwB,CAAC;IAClC,CAAC;CACF,CAAC"}
|
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
2
27
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
28
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
29
|
};
|
|
5
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
31
|
+
var rxjs_1 = require("rxjs");
|
|
32
|
+
var operators_1 = require("rxjs/operators");
|
|
33
|
+
var fs_1 = __importDefault(require("fs"));
|
|
34
|
+
var scan_1 = require("../../scan");
|
|
35
|
+
var serialization_1 = require("@ledgerhq/live-common/account/serialization");
|
|
11
36
|
exports.default = {
|
|
12
37
|
description: "utility for Ledger Live app.json file",
|
|
13
|
-
args: [
|
|
14
|
-
...scan_1.scanCommonOpts,
|
|
38
|
+
args: __spreadArray(__spreadArray([], __read(scan_1.scanCommonOpts), false), [
|
|
15
39
|
{
|
|
16
40
|
name: "appjson",
|
|
17
41
|
type: String,
|
|
@@ -24,33 +48,35 @@ exports.default = {
|
|
|
24
48
|
type: Boolean,
|
|
25
49
|
desc: "add accounts to live data",
|
|
26
50
|
},
|
|
27
|
-
],
|
|
28
|
-
job:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
], false),
|
|
52
|
+
job: function (opts) {
|
|
53
|
+
return (0, scan_1.scan)(opts).pipe((0, operators_1.reduce)(function (accounts, account) { return accounts.concat(account); }, []), (0, operators_1.mergeMap)(function (accounts) {
|
|
54
|
+
var appjsondata = opts.appjson
|
|
55
|
+
? JSON.parse(fs_1.default.readFileSync(opts.appjson, "utf-8"))
|
|
56
|
+
: {
|
|
57
|
+
data: {
|
|
58
|
+
accounts: [],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
if (typeof appjsondata.data.accounts === "string") {
|
|
62
|
+
return (0, rxjs_1.throwError)(function () { return new Error("encrypted ledger live data is not supported"); });
|
|
63
|
+
}
|
|
64
|
+
var existingIds = appjsondata.data.accounts.map(function (a) { return a.data.id; });
|
|
65
|
+
var append = accounts
|
|
66
|
+
.filter(function (a) { return !existingIds.includes(a.id); })
|
|
67
|
+
.map(function (account) { return ({
|
|
68
|
+
data: (0, serialization_1.toAccountRaw)(account),
|
|
69
|
+
version: 1,
|
|
70
|
+
}); });
|
|
71
|
+
appjsondata.data.accounts = appjsondata.data.accounts.concat(append);
|
|
72
|
+
if (opts.appjson) {
|
|
73
|
+
fs_1.default.writeFileSync(opts.appjson, JSON.stringify(appjsondata), "utf-8");
|
|
74
|
+
return (0, rxjs_1.of)(append.length + " accounts added.");
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return (0, rxjs_1.of)(JSON.stringify(appjsondata));
|
|
78
|
+
}
|
|
45
79
|
}));
|
|
46
|
-
|
|
47
|
-
if (opts.appjson) {
|
|
48
|
-
fs_1.default.writeFileSync(opts.appjson, JSON.stringify(appjsondata), "utf-8");
|
|
49
|
-
return (0, rxjs_1.of)(append.length + " accounts added.");
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
return (0, rxjs_1.of)(JSON.stringify(appjsondata));
|
|
53
|
-
}
|
|
54
|
-
})),
|
|
80
|
+
},
|
|
55
81
|
};
|
|
56
82
|
//# sourceMappingURL=liveData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveData.js","sourceRoot":"","sources":["../../../src/commands/live/liveData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"liveData.js","sourceRoot":"","sources":["../../../src/commands/live/liveData.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAsC;AACtC,4CAAkD;AAClD,0CAAoB;AACpB,mCAAkD;AAElD,6EAA2E;AAS3E,kBAAe;IACb,WAAW,EAAE,uCAAuC;IACpD,IAAI,yCACC,qBAAc;QACjB;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,iCAAiC;SACxC;QACD;YACE,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,2BAA2B;SAClC;aACF;IACD,GAAG,EAAE,UAAC,IAAqB;QACzB,OAAA,IAAA,WAAI,EAAC,IAAI,CAAC,CAAC,IAAI,CACb,IAAA,kBAAM,EAAqB,UAAC,QAAQ,EAAE,OAAO,IAAK,OAAA,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAxB,CAAwB,EAAE,EAAE,CAAC,EAC/E,IAAA,oBAAQ,EAAC,UAAA,QAAQ;YACf,IAAM,WAAW,GAAG,IAAI,CAAC,OAAO;gBAC9B,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBACpD,CAAC,CAAC;oBACE,IAAI,EAAE;wBACJ,QAAQ,EAAE,EAAE;qBACb;iBACF,CAAC;YAEN,IAAI,OAAO,WAAW,CAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAClD,OAAO,IAAA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