@shapeshiftoss/hdwallet-keepkey 1.62.39 → 1.62.42
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/LICENSE.md +6 -6
- package/dist/cjs/.tsbuildinfo +1 -0
- package/dist/{adapter.d.ts → cjs/adapter.d.ts} +6 -7
- package/dist/cjs/adapter.js +146 -0
- package/dist/{binance.d.ts → cjs/binance.d.ts} +3 -4
- package/dist/cjs/binance.js +144 -0
- package/dist/{bitcoin.d.ts → cjs/bitcoin.d.ts} +3 -4
- package/dist/cjs/bitcoin.js +549 -0
- package/dist/{bnbencoding.d.ts → cjs/bnbencoding.d.ts} +3 -2
- package/dist/{bnbencoding.js → cjs/bnbencoding.js} +22 -22
- package/dist/{cosmos.d.ts → cjs/cosmos.d.ts} +4 -5
- package/dist/cjs/cosmos.js +219 -0
- package/dist/{eos.d.ts → cjs/eos.d.ts} +3 -4
- package/dist/cjs/eos.js +244 -0
- package/dist/{ethereum.d.ts → cjs/ethereum.d.ts} +4 -5
- package/dist/cjs/ethereum.js +264 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/{index.js → cjs/index.js} +0 -1
- package/dist/{keepkey.d.ts → cjs/keepkey.d.ts} +45 -20
- package/dist/cjs/keepkey.js +959 -0
- package/dist/{mayachain.d.ts → cjs/mayachain.d.ts} +4 -5
- package/dist/cjs/mayachain.js +169 -0
- package/dist/{osmosis.d.ts → cjs/osmosis.d.ts} +4 -5
- package/dist/cjs/osmosis.js +270 -0
- package/dist/cjs/package.json +1 -0
- package/dist/{ripple.d.ts → cjs/ripple.d.ts} +3 -4
- package/dist/cjs/ripple.js +104 -0
- package/dist/{thorchain.d.ts → cjs/thorchain.d.ts} +4 -5
- package/dist/cjs/thorchain.js +169 -0
- package/dist/{transport.d.ts → cjs/transport.d.ts} +2 -3
- package/dist/cjs/transport.js +333 -0
- package/dist/{typeRegistry.d.ts → cjs/typeRegistry.d.ts} +2 -3
- package/dist/{typeRegistry.js → cjs/typeRegistry.js} +26 -13
- package/dist/{utils.d.ts → cjs/utils.d.ts} +1 -2
- package/dist/{utils.js → cjs/utils.js} +7 -8
- package/dist/esm/.tsbuildinfo +1 -0
- package/dist/esm/adapter.d.ts +35 -0
- package/dist/esm/adapter.js +119 -0
- package/dist/esm/binance.d.ts +5 -0
- package/dist/esm/binance.js +112 -0
- package/dist/esm/bitcoin.d.ts +11 -0
- package/dist/esm/bitcoin.js +511 -0
- package/dist/esm/bnbencoding.d.ts +11 -0
- package/dist/esm/bnbencoding.js +103 -0
- package/dist/esm/cosmos.d.ts +6 -0
- package/dist/esm/cosmos.js +187 -0
- package/dist/esm/eos.d.ts +5 -0
- package/dist/esm/eos.js +212 -0
- package/dist/esm/ethereum.d.ts +17 -0
- package/dist/esm/ethereum.js +229 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/keepkey.d.ts +177 -0
- package/dist/esm/keepkey.js +925 -0
- package/dist/esm/mayachain.d.ts +6 -0
- package/dist/esm/mayachain.js +137 -0
- package/dist/esm/osmosis.d.ts +6 -0
- package/dist/esm/osmosis.js +238 -0
- package/dist/esm/ripple.d.ts +5 -0
- package/dist/esm/ripple.js +72 -0
- package/dist/esm/thorchain.d.ts +6 -0
- package/dist/esm/thorchain.js +137 -0
- package/dist/esm/transport.d.ts +55 -0
- package/dist/esm/transport.js +306 -0
- package/dist/esm/typeRegistry.d.ts +4 -0
- package/dist/esm/typeRegistry.js +47 -0
- package/dist/esm/utils.d.ts +6 -0
- package/dist/esm/utils.js +56 -0
- package/package.json +33 -19
- package/dist/adapter.d.ts.map +0 -1
- package/dist/adapter.js +0 -175
- package/dist/adapter.js.map +0 -1
- package/dist/binance.d.ts.map +0 -1
- package/dist/binance.js +0 -146
- package/dist/binance.js.map +0 -1
- package/dist/bitcoin.d.ts.map +0 -1
- package/dist/bitcoin.js +0 -568
- package/dist/bitcoin.js.map +0 -1
- package/dist/bnbencoding.d.ts.map +0 -1
- package/dist/bnbencoding.js.map +0 -1
- package/dist/cosmos.d.ts.map +0 -1
- package/dist/cosmos.js +0 -230
- package/dist/cosmos.js.map +0 -1
- package/dist/eos.d.ts.map +0 -1
- package/dist/eos.js +0 -247
- package/dist/eos.js.map +0 -1
- package/dist/ethereum.d.ts.map +0 -1
- package/dist/ethereum.js +0 -281
- package/dist/ethereum.js.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/keepkey.d.ts.map +0 -1
- package/dist/keepkey.js +0 -1027
- package/dist/keepkey.js.map +0 -1
- package/dist/mayachain.d.ts.map +0 -1
- package/dist/mayachain.js +0 -180
- package/dist/mayachain.js.map +0 -1
- package/dist/osmosis.d.ts.map +0 -1
- package/dist/osmosis.js +0 -278
- package/dist/osmosis.js.map +0 -1
- package/dist/ripple.d.ts.map +0 -1
- package/dist/ripple.js +0 -111
- package/dist/ripple.js.map +0 -1
- package/dist/thorchain.d.ts.map +0 -1
- package/dist/thorchain.js +0 -180
- package/dist/thorchain.js.map +0 -1
- package/dist/transport.d.ts.map +0 -1
- package/dist/transport.js +0 -365
- package/dist/transport.js.map +0 -1
- package/dist/typeRegistry.d.ts.map +0 -1
- package/dist/typeRegistry.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
package/dist/keepkey.js
DELETED
|
@@ -1,1027 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.KeepKeyHDWallet = exports.KeepKeyHDWalletInfo = void 0;
|
|
39
|
-
exports.isKeepKey = isKeepKey;
|
|
40
|
-
exports.info = info;
|
|
41
|
-
exports.create = create;
|
|
42
|
-
const Messages = __importStar(require("@keepkey/device-protocol/lib/messages_pb"));
|
|
43
|
-
const Types = __importStar(require("@keepkey/device-protocol/lib/types_pb"));
|
|
44
|
-
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
45
|
-
const isObject_1 = __importDefault(require("lodash/isObject"));
|
|
46
|
-
const semver_1 = __importDefault(require("semver"));
|
|
47
|
-
const Binance = __importStar(require("./binance"));
|
|
48
|
-
const Btc = __importStar(require("./bitcoin"));
|
|
49
|
-
const Cosmos = __importStar(require("./cosmos"));
|
|
50
|
-
const Eos = __importStar(require("./eos"));
|
|
51
|
-
const Eth = __importStar(require("./ethereum"));
|
|
52
|
-
const Mayachain = __importStar(require("./mayachain"));
|
|
53
|
-
const Osmosis = __importStar(require("./osmosis"));
|
|
54
|
-
const Ripple = __importStar(require("./ripple"));
|
|
55
|
-
const Thorchain = __importStar(require("./thorchain"));
|
|
56
|
-
const typeRegistry_1 = require("./typeRegistry");
|
|
57
|
-
const utils_1 = require("./utils");
|
|
58
|
-
function isKeepKey(wallet) {
|
|
59
|
-
return (0, isObject_1.default)(wallet) && wallet._isKeepKey;
|
|
60
|
-
}
|
|
61
|
-
function describeUTXOPath(path, coin, scriptType) {
|
|
62
|
-
var _a;
|
|
63
|
-
const pathStr = core.addressNListToBIP32(path);
|
|
64
|
-
const unknown = {
|
|
65
|
-
verbose: pathStr,
|
|
66
|
-
coin,
|
|
67
|
-
scriptType,
|
|
68
|
-
isKnown: false,
|
|
69
|
-
};
|
|
70
|
-
if (!scriptType)
|
|
71
|
-
return unknown;
|
|
72
|
-
if (!Btc.btcSupportsCoin(coin))
|
|
73
|
-
return unknown;
|
|
74
|
-
if (!Btc.btcSupportsScriptType(coin, scriptType))
|
|
75
|
-
return unknown;
|
|
76
|
-
if (path.length !== 3 && path.length !== 5)
|
|
77
|
-
return unknown;
|
|
78
|
-
if ((path[0] & 0x80000000) >>> 0 !== 0x80000000)
|
|
79
|
-
return unknown;
|
|
80
|
-
const purpose = path[0] & 0x7fffffff;
|
|
81
|
-
if (![44, 49, 84].includes(purpose))
|
|
82
|
-
return unknown;
|
|
83
|
-
if (purpose === 44 && scriptType !== core.BTCInputScriptType.SpendAddress)
|
|
84
|
-
return unknown;
|
|
85
|
-
if (purpose === 49 && scriptType !== core.BTCInputScriptType.SpendP2SHWitness)
|
|
86
|
-
return unknown;
|
|
87
|
-
if (purpose === 84 && scriptType !== core.BTCInputScriptType.SpendWitness)
|
|
88
|
-
return unknown;
|
|
89
|
-
const wholeAccount = path.length === 3;
|
|
90
|
-
const script = scriptType
|
|
91
|
-
? (_a = {
|
|
92
|
-
[core.BTCInputScriptType.SpendAddress]: ["Legacy"],
|
|
93
|
-
[core.BTCInputScriptType.SpendP2SHWitness]: [],
|
|
94
|
-
[core.BTCInputScriptType.SpendWitness]: ["Segwit Native"],
|
|
95
|
-
}[scriptType]) !== null && _a !== void 0 ? _a : []
|
|
96
|
-
: [];
|
|
97
|
-
let isPrefork = false;
|
|
98
|
-
const slip44 = core.slip44ByCoin(coin);
|
|
99
|
-
if (slip44 === undefined)
|
|
100
|
-
return unknown;
|
|
101
|
-
if (path[1] !== 0x80000000 + slip44) {
|
|
102
|
-
switch (coin) {
|
|
103
|
-
case "BitcoinCash":
|
|
104
|
-
case "BitcoinGold": {
|
|
105
|
-
if (path[1] === 0x80000000 + core.slip44ByCoin("Bitcoin")) {
|
|
106
|
-
isPrefork = true;
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
return unknown;
|
|
110
|
-
}
|
|
111
|
-
case "BitcoinSV": {
|
|
112
|
-
if (path[1] === 0x80000000 + core.slip44ByCoin("Bitcoin") ||
|
|
113
|
-
path[1] === 0x80000000 + core.slip44ByCoin("BitcoinCash")) {
|
|
114
|
-
isPrefork = true;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
return unknown;
|
|
118
|
-
}
|
|
119
|
-
default:
|
|
120
|
-
return unknown;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
let attributes = isPrefork ? ["Prefork"] : [];
|
|
124
|
-
switch (coin) {
|
|
125
|
-
case "Bitcoin":
|
|
126
|
-
case "Litecoin":
|
|
127
|
-
case "BitcoinGold":
|
|
128
|
-
case "Testnet": {
|
|
129
|
-
attributes = attributes.concat(script);
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
default:
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
const attr = attributes.length ? ` (${attributes.join(", ")})` : "";
|
|
136
|
-
const accountIdx = path[2] & 0x7fffffff;
|
|
137
|
-
if (wholeAccount) {
|
|
138
|
-
return {
|
|
139
|
-
coin,
|
|
140
|
-
verbose: `${coin} Account #${accountIdx}${attr}`,
|
|
141
|
-
accountIdx,
|
|
142
|
-
wholeAccount: true,
|
|
143
|
-
isKnown: true,
|
|
144
|
-
scriptType,
|
|
145
|
-
isPrefork,
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
const change = path[3] === 1 ? "Change " : "";
|
|
150
|
-
const addressIdx = path[4];
|
|
151
|
-
return {
|
|
152
|
-
coin,
|
|
153
|
-
verbose: `${coin} Account #${accountIdx}, ${change}Address #${addressIdx}${attr}`,
|
|
154
|
-
accountIdx,
|
|
155
|
-
addressIdx,
|
|
156
|
-
wholeAccount: false,
|
|
157
|
-
isKnown: true,
|
|
158
|
-
isChange: path[3] === 1,
|
|
159
|
-
scriptType,
|
|
160
|
-
isPrefork,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
function describeEosPath(path) {
|
|
165
|
-
const pathStr = core.addressNListToBIP32(path);
|
|
166
|
-
const unknown = {
|
|
167
|
-
verbose: pathStr,
|
|
168
|
-
coin: "Eos",
|
|
169
|
-
isKnown: false,
|
|
170
|
-
};
|
|
171
|
-
if (path.length != 5) {
|
|
172
|
-
return unknown;
|
|
173
|
-
}
|
|
174
|
-
if (path[0] != 0x80000000 + 44) {
|
|
175
|
-
return unknown;
|
|
176
|
-
}
|
|
177
|
-
if (path[1] != 0x80000000 + core.slip44ByCoin("Eos")) {
|
|
178
|
-
return unknown;
|
|
179
|
-
}
|
|
180
|
-
if ((path[2] & 0x80000000) >>> 0 !== 0x80000000) {
|
|
181
|
-
return unknown;
|
|
182
|
-
}
|
|
183
|
-
if (path[3] !== 0 || path[4] !== 0) {
|
|
184
|
-
return unknown;
|
|
185
|
-
}
|
|
186
|
-
const index = path[2] & 0x7fffffff;
|
|
187
|
-
return {
|
|
188
|
-
verbose: `Eos Account #${index}`,
|
|
189
|
-
accountIdx: index,
|
|
190
|
-
wholeAccount: true,
|
|
191
|
-
coin: "Eos",
|
|
192
|
-
isKnown: true,
|
|
193
|
-
isPrefork: false,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function describeRipplePath(path) {
|
|
197
|
-
const pathStr = core.addressNListToBIP32(path);
|
|
198
|
-
const unknown = {
|
|
199
|
-
verbose: pathStr,
|
|
200
|
-
coin: "Ripple",
|
|
201
|
-
isKnown: false,
|
|
202
|
-
};
|
|
203
|
-
if (path.length != 5) {
|
|
204
|
-
return unknown;
|
|
205
|
-
}
|
|
206
|
-
if (path[0] != 0x80000000 + 44) {
|
|
207
|
-
return unknown;
|
|
208
|
-
}
|
|
209
|
-
if (path[1] != 0x80000000 + core.slip44ByCoin("Ripple")) {
|
|
210
|
-
return unknown;
|
|
211
|
-
}
|
|
212
|
-
if ((path[2] & 0x80000000) >>> 0 !== 0x80000000) {
|
|
213
|
-
return unknown;
|
|
214
|
-
}
|
|
215
|
-
if (path[3] !== 0 || path[4] !== 0) {
|
|
216
|
-
return unknown;
|
|
217
|
-
}
|
|
218
|
-
const index = path[2] & 0x7fffffff;
|
|
219
|
-
return {
|
|
220
|
-
verbose: `Ripple Account #${index}`,
|
|
221
|
-
accountIdx: index,
|
|
222
|
-
wholeAccount: true,
|
|
223
|
-
coin: "Ripple",
|
|
224
|
-
isKnown: true,
|
|
225
|
-
isPrefork: false,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
class KeepKeyHDWalletInfo {
|
|
229
|
-
constructor() {
|
|
230
|
-
this._supportsBTCInfo = true;
|
|
231
|
-
this._supportsETHInfo = true;
|
|
232
|
-
this._supportsCosmosInfo = true;
|
|
233
|
-
this._supportsOsmosisInfo = true;
|
|
234
|
-
this._supportsRippleInfo = true;
|
|
235
|
-
this._supportsBinanceInfo = true;
|
|
236
|
-
this._supportsEosInfo = true;
|
|
237
|
-
this._supportsThorchainInfo = true;
|
|
238
|
-
this._supportsMayachainInfo = true;
|
|
239
|
-
}
|
|
240
|
-
getVendor() {
|
|
241
|
-
return "KeepKey";
|
|
242
|
-
}
|
|
243
|
-
btcSupportsCoin(coin) {
|
|
244
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
-
return Btc.btcSupportsCoin(coin);
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
btcSupportsScriptType(coin, scriptType) {
|
|
249
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
-
return Btc.btcSupportsScriptType(coin, scriptType);
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
btcSupportsSecureTransfer() {
|
|
254
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
255
|
-
return Btc.btcSupportsSecureTransfer();
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
btcSupportsNativeShapeShift() {
|
|
259
|
-
return Btc.btcSupportsNativeShapeShift();
|
|
260
|
-
}
|
|
261
|
-
btcGetAccountPaths(msg) {
|
|
262
|
-
return Btc.btcGetAccountPaths(msg);
|
|
263
|
-
}
|
|
264
|
-
ethSupportsNetwork(chain_id) {
|
|
265
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
-
return Eth.ethSupportsNetwork(chain_id);
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
ethSupportsSecureTransfer() {
|
|
270
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
271
|
-
return Eth.ethSupportsSecureTransfer();
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
ethSupportsNativeShapeShift() {
|
|
275
|
-
return Eth.ethSupportsNativeShapeShift();
|
|
276
|
-
}
|
|
277
|
-
ethSupportsEIP1559() {
|
|
278
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
-
// EIP1559 support starts in v7.2.1
|
|
280
|
-
// return semver.gte(await this.getFirmwareVersion(), "v7.2.1");
|
|
281
|
-
// disable EIP1559 support until edge case fail states are fixed across all evm chains
|
|
282
|
-
return false;
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
ethGetAccountPaths(msg) {
|
|
286
|
-
return Eth.ethGetAccountPaths(msg);
|
|
287
|
-
}
|
|
288
|
-
cosmosGetAccountPaths(msg) {
|
|
289
|
-
return Cosmos.cosmosGetAccountPaths(msg);
|
|
290
|
-
}
|
|
291
|
-
osmosisGetAccountPaths(msg) {
|
|
292
|
-
return Osmosis.osmosisGetAccountPaths(msg);
|
|
293
|
-
}
|
|
294
|
-
thorchainGetAccountPaths(msg) {
|
|
295
|
-
return Thorchain.thorchainGetAccountPaths(msg);
|
|
296
|
-
}
|
|
297
|
-
mayachainGetAccountPaths(msg) {
|
|
298
|
-
return Mayachain.mayachainGetAccountPaths(msg);
|
|
299
|
-
}
|
|
300
|
-
rippleGetAccountPaths(msg) {
|
|
301
|
-
return Ripple.rippleGetAccountPaths(msg);
|
|
302
|
-
}
|
|
303
|
-
binanceGetAccountPaths(msg) {
|
|
304
|
-
return Binance.binanceGetAccountPaths(msg);
|
|
305
|
-
}
|
|
306
|
-
eosGetAccountPaths(msg) {
|
|
307
|
-
return Eos.eosGetAccountPaths(msg);
|
|
308
|
-
}
|
|
309
|
-
hasOnDevicePinEntry() {
|
|
310
|
-
return false;
|
|
311
|
-
}
|
|
312
|
-
hasOnDevicePassphrase() {
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
hasOnDeviceDisplay() {
|
|
316
|
-
return true;
|
|
317
|
-
}
|
|
318
|
-
hasOnDeviceRecovery() {
|
|
319
|
-
return false;
|
|
320
|
-
}
|
|
321
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
322
|
-
hasNativeShapeShift(srcCoin, dstCoin) {
|
|
323
|
-
return true;
|
|
324
|
-
}
|
|
325
|
-
supportsBip44Accounts() {
|
|
326
|
-
return true;
|
|
327
|
-
}
|
|
328
|
-
supportsOfflineSigning() {
|
|
329
|
-
return true;
|
|
330
|
-
}
|
|
331
|
-
supportsBroadcast() {
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
describePath(msg) {
|
|
335
|
-
switch (msg.coin) {
|
|
336
|
-
case "Ethereum":
|
|
337
|
-
return core.describeETHPath(msg.path);
|
|
338
|
-
case "Atom":
|
|
339
|
-
return core.cosmosDescribePath(msg.path);
|
|
340
|
-
case "Osmo":
|
|
341
|
-
return core.osmosisDescribePath(msg.path);
|
|
342
|
-
case "Binance":
|
|
343
|
-
return core.binanceDescribePath(msg.path);
|
|
344
|
-
case "Ripple":
|
|
345
|
-
return describeRipplePath(msg.path);
|
|
346
|
-
case "Eos":
|
|
347
|
-
return describeEosPath(msg.path);
|
|
348
|
-
case "Thorchain":
|
|
349
|
-
return core.thorchainDescribePath(msg.path);
|
|
350
|
-
case "Mayachain":
|
|
351
|
-
return core.mayachainDescribePath(msg.path);
|
|
352
|
-
default:
|
|
353
|
-
return describeUTXOPath(msg.path, msg.coin, msg.scriptType);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
btcNextAccountPath(msg) {
|
|
357
|
-
const description = describeUTXOPath(msg.addressNList, msg.coin, msg.scriptType);
|
|
358
|
-
if (!description.isKnown) {
|
|
359
|
-
return undefined;
|
|
360
|
-
}
|
|
361
|
-
const addressNList = msg.addressNList;
|
|
362
|
-
if (addressNList[0] === 0x80000000 + 44 ||
|
|
363
|
-
addressNList[0] === 0x80000000 + 49 ||
|
|
364
|
-
addressNList[0] === 0x80000000 + 84) {
|
|
365
|
-
addressNList[2] += 1;
|
|
366
|
-
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
367
|
-
}
|
|
368
|
-
return undefined;
|
|
369
|
-
}
|
|
370
|
-
ethNextAccountPath(msg) {
|
|
371
|
-
const addressNList = msg.hardenedPath.concat(msg.relPath);
|
|
372
|
-
const description = core.describeETHPath(addressNList);
|
|
373
|
-
if (!description.isKnown) {
|
|
374
|
-
return undefined;
|
|
375
|
-
}
|
|
376
|
-
if (addressNList[0] === 0x80000000 + 44) {
|
|
377
|
-
addressNList[2] += 1;
|
|
378
|
-
return Object.assign(Object.assign({}, msg), { addressNList, hardenedPath: core.hardenedPath(addressNList), relPath: core.relativePath(addressNList) });
|
|
379
|
-
}
|
|
380
|
-
return undefined;
|
|
381
|
-
}
|
|
382
|
-
cosmosNextAccountPath(msg) {
|
|
383
|
-
const description = core.cosmosDescribePath(msg.addressNList);
|
|
384
|
-
if (!description.isKnown) {
|
|
385
|
-
return undefined;
|
|
386
|
-
}
|
|
387
|
-
const addressNList = msg.addressNList;
|
|
388
|
-
addressNList[2] += 1;
|
|
389
|
-
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
390
|
-
}
|
|
391
|
-
osmosisNextAccountPath(msg) {
|
|
392
|
-
const description = core.osmosisDescribePath(msg.addressNList);
|
|
393
|
-
if (!description.isKnown) {
|
|
394
|
-
return undefined;
|
|
395
|
-
}
|
|
396
|
-
const addressNList = msg.addressNList;
|
|
397
|
-
addressNList[2] += 1;
|
|
398
|
-
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
399
|
-
}
|
|
400
|
-
thorchainNextAccountPath(msg) {
|
|
401
|
-
const description = core.thorchainDescribePath(msg.addressNList);
|
|
402
|
-
if (!description.isKnown)
|
|
403
|
-
return undefined;
|
|
404
|
-
const addressNList = msg.addressNList;
|
|
405
|
-
addressNList[2] += 1;
|
|
406
|
-
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
407
|
-
}
|
|
408
|
-
mayachainNextAccountPath(msg) {
|
|
409
|
-
const description = core.mayachainDescribePath(msg.addressNList);
|
|
410
|
-
if (!description.isKnown)
|
|
411
|
-
return undefined;
|
|
412
|
-
const addressNList = msg.addressNList;
|
|
413
|
-
addressNList[2] += 1;
|
|
414
|
-
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
415
|
-
}
|
|
416
|
-
rippleNextAccountPath(msg) {
|
|
417
|
-
const description = describeRipplePath(msg.addressNList);
|
|
418
|
-
if (!description.isKnown) {
|
|
419
|
-
return undefined;
|
|
420
|
-
}
|
|
421
|
-
const addressNList = msg.addressNList;
|
|
422
|
-
addressNList[2] += 1;
|
|
423
|
-
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
424
|
-
}
|
|
425
|
-
binanceNextAccountPath(msg) {
|
|
426
|
-
const description = core.binanceDescribePath(msg.addressNList);
|
|
427
|
-
if (!description.isKnown) {
|
|
428
|
-
return undefined;
|
|
429
|
-
}
|
|
430
|
-
const addressNList = msg.addressNList;
|
|
431
|
-
addressNList[2] += 1;
|
|
432
|
-
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
433
|
-
}
|
|
434
|
-
eosNextAccountPath(msg) {
|
|
435
|
-
const description = describeEosPath(msg.addressNList);
|
|
436
|
-
if (!description.isKnown) {
|
|
437
|
-
return undefined;
|
|
438
|
-
}
|
|
439
|
-
const addressNList = msg.addressNList;
|
|
440
|
-
addressNList[2] += 1;
|
|
441
|
-
return Object.assign(Object.assign({}, msg), { addressNList });
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
exports.KeepKeyHDWalletInfo = KeepKeyHDWalletInfo;
|
|
445
|
-
class KeepKeyHDWallet extends KeepKeyHDWalletInfo {
|
|
446
|
-
constructor(transport) {
|
|
447
|
-
super();
|
|
448
|
-
this._isKeepKey = true;
|
|
449
|
-
this._supportsETH = true;
|
|
450
|
-
this._supportsEthSwitchChain = false;
|
|
451
|
-
this._supportsAvalanche = false;
|
|
452
|
-
this._supportsOptimism = true;
|
|
453
|
-
this._supportsBSC = true;
|
|
454
|
-
this._supportsPolygon = true;
|
|
455
|
-
this._supportsGnosis = true;
|
|
456
|
-
this._supportsArbitrum = true;
|
|
457
|
-
this._supportsArbitrumNova = false;
|
|
458
|
-
this._supportsBase = true;
|
|
459
|
-
this._supportsMonad = false;
|
|
460
|
-
this._supportsPlasma = false;
|
|
461
|
-
this._supportsKatana = false;
|
|
462
|
-
this._supportsHyperEvm = false;
|
|
463
|
-
this._supportsBTC = true;
|
|
464
|
-
this._supportsCosmos = true;
|
|
465
|
-
this._supportsOsmosis = true;
|
|
466
|
-
this._supportsRipple = true;
|
|
467
|
-
this._supportsBinance = true;
|
|
468
|
-
this._supportsEos = true;
|
|
469
|
-
this._supportsThorchain = true;
|
|
470
|
-
this._supportsMayachain = true;
|
|
471
|
-
this.transport = transport;
|
|
472
|
-
this._supportsDebugLink = transport.debugLink;
|
|
473
|
-
this.info = new KeepKeyHDWalletInfo();
|
|
474
|
-
}
|
|
475
|
-
static create(transport) {
|
|
476
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
477
|
-
return new KeepKeyHDWallet(transport);
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
getDeviceID() {
|
|
481
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
482
|
-
const featuresId = (yield this.getFeatures(/*cached=*/ true)).deviceId;
|
|
483
|
-
// Devices in bootloader mode show up with empty string deviceId's in their features object.
|
|
484
|
-
if (featuresId)
|
|
485
|
-
return featuresId;
|
|
486
|
-
// Grabbing the one from the transport seems to be a reasonable fallback.
|
|
487
|
-
return yield this.transport.getDeviceID();
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
getModel() {
|
|
491
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
492
|
-
return core.mustBeDefined((yield this.getFeatures(/*cached=*/ true)).model);
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
getFirmwareVersion() {
|
|
496
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
497
|
-
const features = yield this.getFeatures(/*cached=*/ true);
|
|
498
|
-
return `v${features.majorVersion}.${features.minorVersion}.${features.patchVersion}`;
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
getLabel() {
|
|
502
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
503
|
-
var _a;
|
|
504
|
-
return (_a = (yield this.getFeatures(/*cached=*/ true)).label) !== null && _a !== void 0 ? _a : "";
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
isInitialized() {
|
|
508
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
509
|
-
return !!(yield this.getFeatures()).initialized;
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
isLocked() {
|
|
513
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
514
|
-
const features = yield this.getFeatures();
|
|
515
|
-
if (features.pinProtection && !features.pinCached)
|
|
516
|
-
return true;
|
|
517
|
-
if (features.passphraseProtection && !features.passphraseCached)
|
|
518
|
-
return true;
|
|
519
|
-
return false;
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
getPublicKeys(getPublicKeys) {
|
|
523
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
524
|
-
const publicKeys = [];
|
|
525
|
-
for (let i = 0; i < getPublicKeys.length; i++) {
|
|
526
|
-
const { coin, addressNList, curve, showDisplay, scriptType } = getPublicKeys[i];
|
|
527
|
-
const GPK = new Messages.GetPublicKey();
|
|
528
|
-
if (coin)
|
|
529
|
-
GPK.setCoinName(coin);
|
|
530
|
-
GPK.setAddressNList(addressNList);
|
|
531
|
-
GPK.setShowDisplay(showDisplay || false);
|
|
532
|
-
GPK.setEcdsaCurveName(curve || "secp256k1");
|
|
533
|
-
GPK.setScriptType((0, utils_1.translateInputScriptType)(scriptType || core.BTCInputScriptType.SpendAddress));
|
|
534
|
-
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETPUBLICKEY, GPK, {
|
|
535
|
-
msgTimeout: showDisplay ? core.LONG_TIMEOUT : core.DEFAULT_TIMEOUT,
|
|
536
|
-
});
|
|
537
|
-
const publicKey = event.proto;
|
|
538
|
-
publicKeys.push({ xpub: core.mustBeDefined(publicKey.getXpub()) });
|
|
539
|
-
}
|
|
540
|
-
return publicKeys;
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
ping(msg) {
|
|
544
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
545
|
-
const ping = new Messages.Ping();
|
|
546
|
-
ping.setMessage(msg.msg);
|
|
547
|
-
ping.setButtonProtection(msg.button || false);
|
|
548
|
-
ping.setPinProtection(msg.pin || false);
|
|
549
|
-
ping.setPassphraseProtection(msg.passphrase || false);
|
|
550
|
-
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_PING, ping, {
|
|
551
|
-
msgTimeout: msg.button || msg.pin || msg.passphrase ? core.LONG_TIMEOUT : core.DEFAULT_TIMEOUT,
|
|
552
|
-
});
|
|
553
|
-
const message = event.proto;
|
|
554
|
-
return { msg: core.mustBeDefined(message.getMessage()) };
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
reset(msg) {
|
|
558
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
559
|
-
const resetDevice = new Messages.ResetDevice();
|
|
560
|
-
resetDevice.setStrength(msg.entropy || 128);
|
|
561
|
-
resetDevice.setDisplayRandom(false);
|
|
562
|
-
resetDevice.setPassphraseProtection(msg.passphrase || false);
|
|
563
|
-
resetDevice.setPinProtection(msg.pin || false);
|
|
564
|
-
resetDevice.setLabel(msg.label);
|
|
565
|
-
if (msg.autoLockDelayMs) {
|
|
566
|
-
resetDevice.setAutoLockDelayMs(msg.autoLockDelayMs);
|
|
567
|
-
}
|
|
568
|
-
resetDevice.setU2fCounter(msg.u2fCounter || Math.floor(+new Date() / 1000));
|
|
569
|
-
// resetDevice.setWordsPerGape(wordsPerScreen) // Re-enable when patch gets in
|
|
570
|
-
// Send
|
|
571
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_RESETDEVICE, resetDevice, {
|
|
572
|
-
msgTimeout: core.LONG_TIMEOUT,
|
|
573
|
-
});
|
|
574
|
-
this.cacheFeatures(undefined);
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
recover(r) {
|
|
578
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
579
|
-
const msg = new Messages.RecoveryDevice();
|
|
580
|
-
msg.setWordCount({ 128: 12, 192: 18, 256: 24 }[r.entropy]);
|
|
581
|
-
msg.setPassphraseProtection(r.passphrase);
|
|
582
|
-
msg.setPinProtection(r.pin);
|
|
583
|
-
msg.setLabel(r.label);
|
|
584
|
-
msg.setLanguage(r.language || "english");
|
|
585
|
-
msg.setEnforceWordlist(true);
|
|
586
|
-
msg.setUseCharacterCipher(true);
|
|
587
|
-
if (r.autoLockDelayMs) {
|
|
588
|
-
msg.setAutoLockDelayMs(r.autoLockDelayMs);
|
|
589
|
-
}
|
|
590
|
-
msg.setU2fCounter(r.u2fCounter || Math.floor(+new Date() / 1000));
|
|
591
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_RECOVERYDEVICE, msg, {
|
|
592
|
-
msgTimeout: core.LONG_TIMEOUT,
|
|
593
|
-
});
|
|
594
|
-
this.cacheFeatures(undefined);
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
pressYes() {
|
|
598
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
599
|
-
return this.press(true);
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
pressNo() {
|
|
603
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
604
|
-
return this.press(false);
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
press(isYes) {
|
|
608
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
609
|
-
const decision = new Messages.DebugLinkDecision();
|
|
610
|
-
decision.setYesNo(isYes);
|
|
611
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_DEBUGLINKDECISION, decision, {
|
|
612
|
-
noWait: true,
|
|
613
|
-
debugLink: true,
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
sendPin(pin) {
|
|
618
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
619
|
-
const matrixAck = new Messages.PinMatrixAck();
|
|
620
|
-
matrixAck.setPin(pin);
|
|
621
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_PINMATRIXACK, matrixAck, {
|
|
622
|
-
msgTimeout: core.DEFAULT_TIMEOUT,
|
|
623
|
-
omitLock: true,
|
|
624
|
-
noWait: true,
|
|
625
|
-
});
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
sendPassphrase(passphrase) {
|
|
629
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
630
|
-
const passphraseAck = new Messages.PassphraseAck();
|
|
631
|
-
passphraseAck.setPassphrase(passphrase);
|
|
632
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_PASSPHRASEACK, passphraseAck, {
|
|
633
|
-
msgTimeout: core.DEFAULT_TIMEOUT,
|
|
634
|
-
omitLock: true,
|
|
635
|
-
noWait: true,
|
|
636
|
-
});
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
sendCharacter(character) {
|
|
640
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
641
|
-
yield this.sendCharacterProto(character, false, false);
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
sendCharacterDelete() {
|
|
645
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
646
|
-
yield this.sendCharacterProto("", true, false);
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
sendCharacterDone() {
|
|
650
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
651
|
-
yield this.sendCharacterProto("", false, true);
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
655
|
-
sendWord(word) {
|
|
656
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
657
|
-
throw new Error("Not Yet Implemented :(");
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
sendCharacterProto(character, _delete, _done) {
|
|
661
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
662
|
-
const characterAck = new Messages.CharacterAck();
|
|
663
|
-
if (character !== "") {
|
|
664
|
-
characterAck.setCharacter(character);
|
|
665
|
-
}
|
|
666
|
-
else if (_delete) {
|
|
667
|
-
characterAck.setDelete(_delete);
|
|
668
|
-
}
|
|
669
|
-
else if (_done) {
|
|
670
|
-
characterAck.setDone(_done);
|
|
671
|
-
}
|
|
672
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_CHARACTERACK, characterAck, {
|
|
673
|
-
msgTimeout: core.DEFAULT_TIMEOUT,
|
|
674
|
-
omitLock: true,
|
|
675
|
-
noWait: true,
|
|
676
|
-
});
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
// ApplyPolicy enables or disables a named policy such as "ShapeShift" on the device
|
|
680
|
-
applyPolicy(p) {
|
|
681
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
682
|
-
const policy = new Types.PolicyType();
|
|
683
|
-
policy.setPolicyName(p.policyName);
|
|
684
|
-
policy.setEnabled(p.enabled);
|
|
685
|
-
const applyPolicies = new Messages.ApplyPolicies();
|
|
686
|
-
applyPolicies.setPolicyList([policy]);
|
|
687
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_APPLYPOLICIES, applyPolicies, {
|
|
688
|
-
msgTimeout: core.LONG_TIMEOUT,
|
|
689
|
-
});
|
|
690
|
-
this.cacheFeatures(undefined);
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
// ApplySettings changes the label, language, and enabling/disabling the passphrase
|
|
694
|
-
// The default language is english
|
|
695
|
-
applySettings(s) {
|
|
696
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
697
|
-
const applySettings = new Messages.ApplySettings();
|
|
698
|
-
if (s.label) {
|
|
699
|
-
applySettings.setLabel(s.label);
|
|
700
|
-
}
|
|
701
|
-
if (s.language) {
|
|
702
|
-
applySettings.setLanguage(s.language);
|
|
703
|
-
}
|
|
704
|
-
if (s.usePassphrase !== undefined) {
|
|
705
|
-
applySettings.setUsePassphrase(s.usePassphrase);
|
|
706
|
-
}
|
|
707
|
-
if (s.autoLockDelayMs) {
|
|
708
|
-
applySettings.setAutoLockDelayMs(s.autoLockDelayMs);
|
|
709
|
-
}
|
|
710
|
-
if (s.u2fCounter) {
|
|
711
|
-
applySettings.setU2fCounter(s.u2fCounter);
|
|
712
|
-
}
|
|
713
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_APPLYSETTINGS, applySettings);
|
|
714
|
-
this.cacheFeatures(undefined);
|
|
715
|
-
});
|
|
716
|
-
}
|
|
717
|
-
// Cancel aborts the last device action that required user interaction
|
|
718
|
-
// It can follow a button request, passphrase request, or pin request
|
|
719
|
-
cancel() {
|
|
720
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
721
|
-
yield this.transport.cancel();
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
// ChangePin requests setting/changing the pin
|
|
725
|
-
changePin() {
|
|
726
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
727
|
-
const changePin = new Messages.ChangePin();
|
|
728
|
-
// User may be propmpted for button press up to 2 times
|
|
729
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_CHANGEPIN, changePin, {
|
|
730
|
-
msgTimeout: core.LONG_TIMEOUT,
|
|
731
|
-
});
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
// CipherKeyValue encrypts or decrypts a value with a given key, nodepath, and initializationVector
|
|
735
|
-
// This method encrypts if encrypt is true and decrypts if false, the confirm paramater determines wether
|
|
736
|
-
// the user is prompted on the device. See EncryptKeyValue() and DecryptKeyValue() for convenience methods
|
|
737
|
-
// NOTE: If the length of the value in bytes is not divisible by 16 it will be zero padded
|
|
738
|
-
cipherKeyValue(v) {
|
|
739
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
740
|
-
// if(val.length % 16 !== 0) val = val.concat() TODO THIS
|
|
741
|
-
const cipherKeyValue = new Messages.CipherKeyValue();
|
|
742
|
-
cipherKeyValue.setAddressNList(v.addressNList);
|
|
743
|
-
cipherKeyValue.setKey(v.key);
|
|
744
|
-
cipherKeyValue.setValue(v.value);
|
|
745
|
-
cipherKeyValue.setEncrypt(!!v.encrypt);
|
|
746
|
-
cipherKeyValue.setAskOnEncrypt(v.askOnEncrypt || false);
|
|
747
|
-
cipherKeyValue.setAskOnDecrypt(v.askOnDecrypt || false);
|
|
748
|
-
cipherKeyValue.setIv(v.iv || "");
|
|
749
|
-
const response = yield this.transport.call(Messages.MessageType.MESSAGETYPE_CIPHERKEYVALUE, cipherKeyValue);
|
|
750
|
-
const ckv = response.message;
|
|
751
|
-
return ckv.getValue();
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
// ClearSession clears cached session values such as the pin and passphrase
|
|
755
|
-
clearSession() {
|
|
756
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
757
|
-
const clearSession = new Messages.ClearSession();
|
|
758
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_CLEARSESSION, clearSession);
|
|
759
|
-
this.cacheFeatures(undefined);
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
// DecryptKeyValue is a convenience method around decrypting with CipherKeyValue().
|
|
763
|
-
// For more granular control of the process use CipherKeyValue()
|
|
764
|
-
decryptKeyValue(v) {
|
|
765
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
766
|
-
return this.cipherKeyValue(v);
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
// FirmwareErase askes the device to erase its firmware
|
|
770
|
-
firmwareErase() {
|
|
771
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
772
|
-
const firmwareErase = new Messages.FirmwareErase();
|
|
773
|
-
// send
|
|
774
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_FIRMWAREERASE, firmwareErase);
|
|
775
|
-
this.cacheFeatures(undefined);
|
|
776
|
-
});
|
|
777
|
-
}
|
|
778
|
-
firmwareUpload(firmware) {
|
|
779
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
780
|
-
const firmwareUpload = new Messages.FirmwareUpload();
|
|
781
|
-
const hash = yield this.transport.getFirmwareHash(firmware);
|
|
782
|
-
firmwareUpload.setPayload(firmware);
|
|
783
|
-
firmwareUpload.setPayloadHash(hash);
|
|
784
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_FIRMWAREUPLOAD, firmwareUpload);
|
|
785
|
-
this.cacheFeatures(undefined);
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
// Initialize assigns a hid connection to this KeepKey and send initialize message to device
|
|
789
|
-
initialize() {
|
|
790
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
791
|
-
const initialize = new Messages.Initialize();
|
|
792
|
-
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_INITIALIZE, initialize);
|
|
793
|
-
if (!event.message)
|
|
794
|
-
throw event;
|
|
795
|
-
const out = event.message;
|
|
796
|
-
this.features = out;
|
|
797
|
-
// v6.1.0 firmware changed usb serial numbers to match STM32 desig_device_id
|
|
798
|
-
// If the deviceId in the features table doesn't match, then we need to
|
|
799
|
-
// add another k-v pair to the keyring so it can be looked up either way.
|
|
800
|
-
const transportDeviceID = yield this.transport.getDeviceID();
|
|
801
|
-
if (out.deviceId && transportDeviceID !== out.deviceId) {
|
|
802
|
-
this.transport.keyring.addAlias(transportDeviceID, out.deviceId);
|
|
803
|
-
}
|
|
804
|
-
const fwVersion = `v${out.majorVersion}.${out.minorVersion}.${out.patchVersion}`;
|
|
805
|
-
//Lost Support per proto 44.3
|
|
806
|
-
this._supportsOsmosis = semver_1.default.gte(fwVersion, "v7.7.0");
|
|
807
|
-
this._supportsCosmos = semver_1.default.gte(fwVersion, "v7.3.0");
|
|
808
|
-
this._supportsRipple = semver_1.default.gte(fwVersion, "v6.4.0");
|
|
809
|
-
this._supportsBinance = semver_1.default.gte(fwVersion, "v6.4.0");
|
|
810
|
-
this._supportsEos = semver_1.default.gte(fwVersion, "v6.4.0");
|
|
811
|
-
// this._supportsThorchain = semver.get(fwVersion, "v7.3.0");
|
|
812
|
-
this.cacheFeatures(out);
|
|
813
|
-
return out;
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
// GetFeatures returns the features and other device information such as the version, label, and supported coins
|
|
817
|
-
getFeatures() {
|
|
818
|
-
return __awaiter(this, arguments, void 0, function* (cached = false) {
|
|
819
|
-
if (cached && this.featuresCache)
|
|
820
|
-
return this.featuresCache;
|
|
821
|
-
const features = new Messages.GetFeatures();
|
|
822
|
-
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETFEATURES, features);
|
|
823
|
-
this.cacheFeatures(event.message);
|
|
824
|
-
return event.message;
|
|
825
|
-
});
|
|
826
|
-
}
|
|
827
|
-
cacheFeatures(features) {
|
|
828
|
-
this.featuresCache = features;
|
|
829
|
-
}
|
|
830
|
-
// GetEntropy requests sample data from the hardware RNG
|
|
831
|
-
getEntropy(size) {
|
|
832
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
833
|
-
const getEntropy = new Messages.GetEntropy();
|
|
834
|
-
getEntropy.setSize(size);
|
|
835
|
-
// send
|
|
836
|
-
const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETENTROPY, getEntropy, {
|
|
837
|
-
msgTimeout: core.LONG_TIMEOUT,
|
|
838
|
-
});
|
|
839
|
-
return core.mustBeDefined(event.proto).getEntropy_asU8();
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
// GetNumCoins returns the number of coins supported by the device regardless of if the hanve funds.
|
|
843
|
-
getNumCoins() {
|
|
844
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
845
|
-
const getCoinTable = new Messages.GetCoinTable();
|
|
846
|
-
const response = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETCOINTABLE, getCoinTable);
|
|
847
|
-
return core.mustBeDefined(core.mustBeDefined(response.proto).getNumCoins());
|
|
848
|
-
});
|
|
849
|
-
}
|
|
850
|
-
// GetCoinTable returns an array of Types.CoinTypes, with start and end arguments for paging.
|
|
851
|
-
// You cannot request more than 10 at a time.
|
|
852
|
-
getCoinTable() {
|
|
853
|
-
return __awaiter(this, arguments, void 0, function* (start = 0, end = start + 10) {
|
|
854
|
-
const getCoinTable = new Messages.GetCoinTable();
|
|
855
|
-
getCoinTable.setStart(start);
|
|
856
|
-
getCoinTable.setEnd(end);
|
|
857
|
-
const response = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETCOINTABLE, getCoinTable);
|
|
858
|
-
const coinTable = response.message;
|
|
859
|
-
return coinTable.tableList;
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
// LoadDevice loads a provided seed onto the device and applies the provided settings
|
|
863
|
-
// including setting a pin/device label, enabling/disabling the passphrase, and whether to
|
|
864
|
-
// check the checksum of the provided mnemonic
|
|
865
|
-
loadDevice(msg) {
|
|
866
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
867
|
-
const loadDevice = new Messages.LoadDevice();
|
|
868
|
-
loadDevice.setMnemonic(msg.mnemonic);
|
|
869
|
-
loadDevice.setPassphraseProtection(!!msg.passphrase);
|
|
870
|
-
loadDevice.setSkipChecksum(!!msg.skipChecksum);
|
|
871
|
-
if (msg.pin)
|
|
872
|
-
loadDevice.setPin(msg.pin);
|
|
873
|
-
if (msg.label)
|
|
874
|
-
loadDevice.setLabel(msg.label);
|
|
875
|
-
// send
|
|
876
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_LOADDEVICE, loadDevice, {
|
|
877
|
-
msgTimeout: core.LONG_TIMEOUT,
|
|
878
|
-
});
|
|
879
|
-
this.cacheFeatures(undefined);
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
// RemovePin disables pin protection for the device. If a pin is currently enabled
|
|
883
|
-
// it will prompt the user to enter the current pin
|
|
884
|
-
removePin() {
|
|
885
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
886
|
-
const changePin = new Messages.ChangePin();
|
|
887
|
-
changePin.setRemove(true);
|
|
888
|
-
// send
|
|
889
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_CHANGEPIN, changePin);
|
|
890
|
-
this.cacheFeatures(undefined);
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
send(events) {
|
|
894
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
895
|
-
for (const event of events) {
|
|
896
|
-
const MessageType = typeRegistry_1.messageTypeRegistry[core.mustBeDefined(event.message_enum)];
|
|
897
|
-
const msg = new MessageType();
|
|
898
|
-
Object.entries(event.message).forEach(([key, value]) => {
|
|
899
|
-
const setterMethod = (0, utils_1.protoFieldToSetMethod)(key);
|
|
900
|
-
if (msg[setterMethod]) {
|
|
901
|
-
// Assume setter methods are always of the format: strength -> setStrength
|
|
902
|
-
// until this exists https://github.com/protocolbuffers/protobuf/issues/1591
|
|
903
|
-
msg[setterMethod](value);
|
|
904
|
-
}
|
|
905
|
-
});
|
|
906
|
-
yield this.transport.call(core.mustBeDefined(event.message_enum), msg);
|
|
907
|
-
}
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
// SoftReset power cycles the device. The device only responds to
|
|
911
|
-
// this message while in manufacturer mode
|
|
912
|
-
softReset() {
|
|
913
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
914
|
-
const softReset = new Messages.SoftReset();
|
|
915
|
-
// send
|
|
916
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_SOFTRESET, softReset);
|
|
917
|
-
this.cacheFeatures(undefined);
|
|
918
|
-
});
|
|
919
|
-
}
|
|
920
|
-
// WipeDevice wipes all sensitive data and settings
|
|
921
|
-
wipe() {
|
|
922
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
923
|
-
const wipeDevice = new Messages.WipeDevice();
|
|
924
|
-
// send
|
|
925
|
-
yield this.transport.call(Messages.MessageType.MESSAGETYPE_WIPEDEVICE, wipeDevice);
|
|
926
|
-
this.cacheFeatures(undefined);
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
btcGetAddress(msg) {
|
|
930
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
931
|
-
return Btc.btcGetAddress(this, this.transport, msg);
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
|
-
btcSignTx(msg) {
|
|
935
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
936
|
-
return Btc.btcSignTx(this, this.transport, msg);
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
btcSignMessage(msg) {
|
|
940
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
941
|
-
return Btc.btcSignMessage(this, this.transport, msg);
|
|
942
|
-
});
|
|
943
|
-
}
|
|
944
|
-
btcVerifyMessage(msg) {
|
|
945
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
946
|
-
return Btc.btcVerifyMessage(this, this.transport, msg);
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
ethSignTx(msg) {
|
|
950
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
951
|
-
return Eth.ethSignTx(this.transport, msg);
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
ethGetAddress(msg) {
|
|
955
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
956
|
-
return Eth.ethGetAddress(this.transport, msg);
|
|
957
|
-
});
|
|
958
|
-
}
|
|
959
|
-
ethSignMessage(msg) {
|
|
960
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
961
|
-
return Eth.ethSignMessage(this.transport, msg);
|
|
962
|
-
});
|
|
963
|
-
}
|
|
964
|
-
ethSignTypedData(msg) {
|
|
965
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
966
|
-
return Eth.ethSignTypedData(this.transport, msg);
|
|
967
|
-
});
|
|
968
|
-
}
|
|
969
|
-
ethVerifyMessage(msg) {
|
|
970
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
971
|
-
return Eth.ethVerifyMessage(this.transport, msg);
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
rippleGetAddress(msg) {
|
|
975
|
-
return Ripple.rippleGetAddress(this.transport, msg);
|
|
976
|
-
}
|
|
977
|
-
rippleSignTx(msg) {
|
|
978
|
-
return Ripple.rippleSignTx(this.transport, msg);
|
|
979
|
-
}
|
|
980
|
-
cosmosGetAddress(msg) {
|
|
981
|
-
return Cosmos.cosmosGetAddress(this.transport, msg);
|
|
982
|
-
}
|
|
983
|
-
cosmosSignTx(msg) {
|
|
984
|
-
return Cosmos.cosmosSignTx(this.transport, msg);
|
|
985
|
-
}
|
|
986
|
-
osmosisGetAddress(msg) {
|
|
987
|
-
return Osmosis.osmosisGetAddress(this.transport, msg);
|
|
988
|
-
}
|
|
989
|
-
osmosisSignTx(msg) {
|
|
990
|
-
return Osmosis.osmosisSignTx(this.transport, msg);
|
|
991
|
-
}
|
|
992
|
-
thorchainGetAddress(msg) {
|
|
993
|
-
return Thorchain.thorchainGetAddress(this.transport, msg);
|
|
994
|
-
}
|
|
995
|
-
thorchainSignTx(msg) {
|
|
996
|
-
return Thorchain.thorchainSignTx(this.transport, msg);
|
|
997
|
-
}
|
|
998
|
-
mayachainGetAddress(msg) {
|
|
999
|
-
return Mayachain.mayachainGetAddress(this.transport, msg);
|
|
1000
|
-
}
|
|
1001
|
-
mayachainSignTx(msg) {
|
|
1002
|
-
return Mayachain.mayachainSignTx(this.transport, msg);
|
|
1003
|
-
}
|
|
1004
|
-
binanceGetAddress(msg) {
|
|
1005
|
-
return Binance.binanceGetAddress(this.transport, msg);
|
|
1006
|
-
}
|
|
1007
|
-
binanceSignTx(msg) {
|
|
1008
|
-
return Binance.binanceSignTx(this.transport, msg);
|
|
1009
|
-
}
|
|
1010
|
-
eosGetPublicKey(msg) {
|
|
1011
|
-
return Eos.eosGetPublicKey(this.transport, msg);
|
|
1012
|
-
}
|
|
1013
|
-
eosSignTx(msg) {
|
|
1014
|
-
return Eos.eosSignTx(this.transport, msg);
|
|
1015
|
-
}
|
|
1016
|
-
disconnect() {
|
|
1017
|
-
return this.transport.disconnect();
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
exports.KeepKeyHDWallet = KeepKeyHDWallet;
|
|
1021
|
-
function info() {
|
|
1022
|
-
return new KeepKeyHDWalletInfo();
|
|
1023
|
-
}
|
|
1024
|
-
function create(transport) {
|
|
1025
|
-
return new KeepKeyHDWallet(transport);
|
|
1026
|
-
}
|
|
1027
|
-
//# sourceMappingURL=keepkey.js.map
|