@shapeshiftoss/hdwallet-keepkey 1.55.2 → 1.55.4-alpha.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/dist/keepkey.js CHANGED
@@ -1,60 +1,21 @@
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.create = exports.info = exports.KeepKeyHDWallet = exports.KeepKeyHDWalletInfo = exports.isKeepKey = void 0;
39
- const Messages = __importStar(require("@keepkey/device-protocol/lib/messages_pb"));
40
- const Types = __importStar(require("@keepkey/device-protocol/lib/types_pb"));
41
- const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
42
- const lodash_1 = __importDefault(require("lodash"));
43
- const semver_1 = __importDefault(require("semver"));
44
- const Binance = __importStar(require("./binance"));
45
- const Btc = __importStar(require("./bitcoin"));
46
- const Cosmos = __importStar(require("./cosmos"));
47
- const Eos = __importStar(require("./eos"));
48
- const Eth = __importStar(require("./ethereum"));
49
- const Osmosis = __importStar(require("./osmosis"));
50
- const Ripple = __importStar(require("./ripple"));
51
- const Thorchain = __importStar(require("./thorchain"));
52
- const typeRegistry_1 = require("./typeRegistry");
53
- const utils_1 = require("./utils");
54
- function isKeepKey(wallet) {
55
- return lodash_1.default.isObject(wallet) && wallet._isKeepKey;
1
+ import * as Messages from "@keepkey/device-protocol/lib/messages_pb";
2
+ import * as Types from "@keepkey/device-protocol/lib/types_pb";
3
+ import * as core from "@shapeshiftoss/hdwallet-core";
4
+ import _ from "lodash";
5
+ import semver from "semver";
6
+ import * as Binance from "./binance";
7
+ import * as Btc from "./bitcoin";
8
+ import * as Cosmos from "./cosmos";
9
+ import * as Eos from "./eos";
10
+ import * as Eth from "./ethereum";
11
+ import * as Osmosis from "./osmosis";
12
+ import * as Ripple from "./ripple";
13
+ import * as Thorchain from "./thorchain";
14
+ import { messageTypeRegistry } from "./typeRegistry";
15
+ import { protoFieldToSetMethod, translateInputScriptType } from "./utils";
16
+ export function isKeepKey(wallet) {
17
+ return _.isObject(wallet) && wallet._isKeepKey;
56
18
  }
57
- exports.isKeepKey = isKeepKey;
58
19
  function describeETHPath(path) {
59
20
  const pathStr = core.addressNListToBIP32(path);
60
21
  const unknown = {
@@ -85,7 +46,6 @@ function describeETHPath(path) {
85
46
  };
86
47
  }
87
48
  function describeUTXOPath(path, coin, scriptType) {
88
- var _a;
89
49
  const pathStr = core.addressNListToBIP32(path);
90
50
  const unknown = {
91
51
  verbose: pathStr,
@@ -114,11 +74,11 @@ function describeUTXOPath(path, coin, scriptType) {
114
74
  return unknown;
115
75
  const wholeAccount = path.length === 3;
116
76
  const script = scriptType
117
- ? (_a = {
77
+ ? {
118
78
  [core.BTCInputScriptType.SpendAddress]: ["Legacy"],
119
79
  [core.BTCInputScriptType.SpendP2SHWitness]: [],
120
80
  [core.BTCInputScriptType.SpendWitness]: ["Segwit Native"],
121
- }[scriptType]) !== null && _a !== void 0 ? _a : []
81
+ }[scriptType] ?? []
122
82
  : [];
123
83
  let isPrefork = false;
124
84
  const slip44 = core.slip44ByCoin(coin);
@@ -379,34 +339,26 @@ function describeBinancePath(path) {
379
339
  isPrefork: false,
380
340
  };
381
341
  }
382
- class KeepKeyHDWalletInfo {
383
- constructor() {
384
- this._supportsBTCInfo = true;
385
- this._supportsETHInfo = true;
386
- this._supportsCosmosInfo = true;
387
- this._supportsOsmosisInfo = true;
388
- this._supportsRippleInfo = true;
389
- this._supportsBinanceInfo = true;
390
- this._supportsEosInfo = true;
391
- this._supportsThorchainInfo = true;
392
- }
342
+ export class KeepKeyHDWalletInfo {
343
+ _supportsBTCInfo = true;
344
+ _supportsETHInfo = true;
345
+ _supportsCosmosInfo = true;
346
+ _supportsOsmosisInfo = true;
347
+ _supportsRippleInfo = true;
348
+ _supportsBinanceInfo = true;
349
+ _supportsEosInfo = true;
350
+ _supportsThorchainInfo = true;
393
351
  getVendor() {
394
352
  return "KeepKey";
395
353
  }
396
- btcSupportsCoin(coin) {
397
- return __awaiter(this, void 0, void 0, function* () {
398
- return Btc.btcSupportsCoin(coin);
399
- });
354
+ async btcSupportsCoin(coin) {
355
+ return Btc.btcSupportsCoin(coin);
400
356
  }
401
- btcSupportsScriptType(coin, scriptType) {
402
- return __awaiter(this, void 0, void 0, function* () {
403
- return Btc.btcSupportsScriptType(coin, scriptType);
404
- });
357
+ async btcSupportsScriptType(coin, scriptType) {
358
+ return Btc.btcSupportsScriptType(coin, scriptType);
405
359
  }
406
- btcSupportsSecureTransfer() {
407
- return __awaiter(this, void 0, void 0, function* () {
408
- return Btc.btcSupportsSecureTransfer();
409
- });
360
+ async btcSupportsSecureTransfer() {
361
+ return Btc.btcSupportsSecureTransfer();
410
362
  }
411
363
  btcSupportsNativeShapeShift() {
412
364
  return Btc.btcSupportsNativeShapeShift();
@@ -417,24 +369,18 @@ class KeepKeyHDWalletInfo {
417
369
  btcIsSameAccount(msg) {
418
370
  return Btc.btcIsSameAccount(msg);
419
371
  }
420
- ethSupportsNetwork(chain_id) {
421
- return __awaiter(this, void 0, void 0, function* () {
422
- return Eth.ethSupportsNetwork(chain_id);
423
- });
372
+ async ethSupportsNetwork(chain_id) {
373
+ return Eth.ethSupportsNetwork(chain_id);
424
374
  }
425
- ethSupportsSecureTransfer() {
426
- return __awaiter(this, void 0, void 0, function* () {
427
- return Eth.ethSupportsSecureTransfer();
428
- });
375
+ async ethSupportsSecureTransfer() {
376
+ return Eth.ethSupportsSecureTransfer();
429
377
  }
430
378
  ethSupportsNativeShapeShift() {
431
379
  return Eth.ethSupportsNativeShapeShift();
432
380
  }
433
- ethSupportsEIP1559() {
434
- return __awaiter(this, void 0, void 0, function* () {
435
- // disable EIP1559 support until edge case fail states are fixed across all evm chains
436
- return false;
437
- });
381
+ async ethSupportsEIP1559() {
382
+ // disable EIP1559 support until edge case fail states are fixed across all evm chains
383
+ return false;
438
384
  }
439
385
  ethGetAccountPaths(msg) {
440
386
  return Eth.ethGetAccountPaths(msg);
@@ -510,7 +456,10 @@ class KeepKeyHDWalletInfo {
510
456
  addressNList[0] === 0x80000000 + 49 ||
511
457
  addressNList[0] === 0x80000000 + 84) {
512
458
  addressNList[2] += 1;
513
- return Object.assign(Object.assign({}, msg), { addressNList });
459
+ return {
460
+ ...msg,
461
+ addressNList,
462
+ };
514
463
  }
515
464
  return undefined;
516
465
  }
@@ -522,7 +471,12 @@ class KeepKeyHDWalletInfo {
522
471
  }
523
472
  if (addressNList[0] === 0x80000000 + 44) {
524
473
  addressNList[2] += 1;
525
- return Object.assign(Object.assign({}, msg), { addressNList, hardenedPath: core.hardenedPath(addressNList), relPath: core.relativePath(addressNList) });
474
+ return {
475
+ ...msg,
476
+ addressNList,
477
+ hardenedPath: core.hardenedPath(addressNList),
478
+ relPath: core.relativePath(addressNList),
479
+ };
526
480
  }
527
481
  return undefined;
528
482
  }
@@ -533,7 +487,10 @@ class KeepKeyHDWalletInfo {
533
487
  }
534
488
  const addressNList = msg.addressNList;
535
489
  addressNList[2] += 1;
536
- return Object.assign(Object.assign({}, msg), { addressNList });
490
+ return {
491
+ ...msg,
492
+ addressNList,
493
+ };
537
494
  }
538
495
  osmosisNextAccountPath(msg) {
539
496
  const description = describeOsmosisPath(msg.addressNList);
@@ -542,7 +499,10 @@ class KeepKeyHDWalletInfo {
542
499
  }
543
500
  const addressNList = msg.addressNList;
544
501
  addressNList[2] += 1;
545
- return Object.assign(Object.assign({}, msg), { addressNList });
502
+ return {
503
+ ...msg,
504
+ addressNList,
505
+ };
546
506
  }
547
507
  thorchainNextAccountPath(msg) {
548
508
  const description = describeThorchainPath(msg.addressNList);
@@ -551,7 +511,10 @@ class KeepKeyHDWalletInfo {
551
511
  }
552
512
  const addressNList = msg.addressNList;
553
513
  addressNList[2] += 1;
554
- return Object.assign(Object.assign({}, msg), { addressNList });
514
+ return {
515
+ ...msg,
516
+ addressNList,
517
+ };
555
518
  }
556
519
  rippleNextAccountPath(msg) {
557
520
  const description = describeRipplePath(msg.addressNList);
@@ -560,7 +523,10 @@ class KeepKeyHDWalletInfo {
560
523
  }
561
524
  const addressNList = msg.addressNList;
562
525
  addressNList[2] += 1;
563
- return Object.assign(Object.assign({}, msg), { addressNList });
526
+ return {
527
+ ...msg,
528
+ addressNList,
529
+ };
564
530
  }
565
531
  binanceNextAccountPath(msg) {
566
532
  const description = describeBinancePath(msg.addressNList);
@@ -569,7 +535,10 @@ class KeepKeyHDWalletInfo {
569
535
  }
570
536
  const addressNList = msg.addressNList;
571
537
  addressNList[2] += 1;
572
- return Object.assign(Object.assign({}, msg), { addressNList });
538
+ return {
539
+ ...msg,
540
+ addressNList,
541
+ };
573
542
  }
574
543
  eosNextAccountPath(msg) {
575
544
  const description = describeEosPath(msg.addressNList);
@@ -578,193 +547,171 @@ class KeepKeyHDWalletInfo {
578
547
  }
579
548
  const addressNList = msg.addressNList;
580
549
  addressNList[2] += 1;
581
- return Object.assign(Object.assign({}, msg), { addressNList });
550
+ return {
551
+ ...msg,
552
+ addressNList,
553
+ };
582
554
  }
583
555
  }
584
- exports.KeepKeyHDWalletInfo = KeepKeyHDWalletInfo;
585
- class KeepKeyHDWallet {
556
+ export class KeepKeyHDWallet {
557
+ _supportsETHInfo = true;
558
+ _supportsBTCInfo = true;
559
+ _supportsCosmosInfo = true;
560
+ _supportsOsmosisInfo = true;
561
+ _supportsRippleInfo = true;
562
+ _supportsBinanceInfo = true;
563
+ _supportsEosInfo = true;
564
+ _supportsFioInfo = false;
565
+ _supportsDebugLink;
566
+ _isKeepKey = true;
567
+ _supportsETH = true;
568
+ _supportsEthSwitchChain = false;
569
+ _supportsAvalanche = false;
570
+ _supportsOptimism = true;
571
+ _supportsBSC = true;
572
+ _supportsPolygon = true;
573
+ _supportsGnosis = true;
574
+ _supportsArbitrum = true;
575
+ _supportsArbitrumNova = false;
576
+ _supportsBase = true;
577
+ _supportsBTC = true;
578
+ _supportsCosmos = true;
579
+ _supportsOsmosis = true;
580
+ _supportsRipple = true;
581
+ _supportsBinance = true;
582
+ _supportsEos = true;
583
+ _supportsFio = false;
584
+ _supportsThorchainInfo = true;
585
+ _supportsThorchain = true;
586
+ _supportsSecretInfo = false;
587
+ _supportsSecret = false;
588
+ _supportsKava = false;
589
+ _supportsKavaInfo = false;
590
+ _supportsTerra = false;
591
+ _supportsTerraInfo = false;
592
+ transport;
593
+ features;
594
+ info;
595
+ featuresCache;
586
596
  constructor(transport) {
587
- this._supportsETHInfo = true;
588
- this._supportsBTCInfo = true;
589
- this._supportsCosmosInfo = true;
590
- this._supportsOsmosisInfo = true;
591
- this._supportsRippleInfo = true;
592
- this._supportsBinanceInfo = true;
593
- this._supportsEosInfo = true;
594
- this._supportsFioInfo = false;
595
- this._isKeepKey = true;
596
- this._supportsETH = true;
597
- this._supportsEthSwitchChain = false;
598
- this._supportsAvalanche = false;
599
- this._supportsOptimism = true;
600
- this._supportsBSC = true;
601
- this._supportsPolygon = true;
602
- this._supportsGnosis = true;
603
- this._supportsArbitrum = true;
604
- this._supportsArbitrumNova = false;
605
- this._supportsBase = true;
606
- this._supportsBTC = true;
607
- this._supportsCosmos = true;
608
- this._supportsOsmosis = true;
609
- this._supportsRipple = true;
610
- this._supportsBinance = true;
611
- this._supportsEos = true;
612
- this._supportsFio = false;
613
- this._supportsThorchainInfo = true;
614
- this._supportsThorchain = true;
615
- this._supportsSecretInfo = false;
616
- this._supportsSecret = false;
617
- this._supportsKava = false;
618
- this._supportsKavaInfo = false;
619
- this._supportsTerra = false;
620
- this._supportsTerraInfo = false;
621
597
  this.transport = transport;
622
598
  this._supportsDebugLink = transport.debugLink;
623
599
  this.info = new KeepKeyHDWalletInfo();
624
600
  }
625
- static create(transport) {
626
- return __awaiter(this, void 0, void 0, function* () {
627
- return new KeepKeyHDWallet(transport);
628
- });
601
+ static async create(transport) {
602
+ return new KeepKeyHDWallet(transport);
629
603
  }
630
- getDeviceID() {
631
- return __awaiter(this, void 0, void 0, function* () {
632
- const featuresId = (yield this.getFeatures(/*cached=*/ true)).deviceId;
633
- // Devices in bootloader mode show up with empty string deviceId's in their features object.
634
- if (featuresId)
635
- return featuresId;
636
- // Grabbing the one from the transport seems to be a reasonable fallback.
637
- return yield this.transport.getDeviceID();
638
- });
604
+ async getDeviceID() {
605
+ const featuresId = (await this.getFeatures(/*cached=*/ true)).deviceId;
606
+ // Devices in bootloader mode show up with empty string deviceId's in their features object.
607
+ if (featuresId)
608
+ return featuresId;
609
+ // Grabbing the one from the transport seems to be a reasonable fallback.
610
+ return await this.transport.getDeviceID();
639
611
  }
640
612
  getVendor() {
641
613
  return "KeepKey";
642
614
  }
643
- getModel() {
644
- return __awaiter(this, void 0, void 0, function* () {
645
- return core.mustBeDefined((yield this.getFeatures(/*cached=*/ true)).model);
646
- });
615
+ async getModel() {
616
+ return core.mustBeDefined((await this.getFeatures(/*cached=*/ true)).model);
647
617
  }
648
- getFirmwareVersion() {
649
- return __awaiter(this, void 0, void 0, function* () {
650
- const features = yield this.getFeatures(/*cached=*/ true);
651
- return `v${features.majorVersion}.${features.minorVersion}.${features.patchVersion}`;
652
- });
618
+ async getFirmwareVersion() {
619
+ const features = await this.getFeatures(/*cached=*/ true);
620
+ return `v${features.majorVersion}.${features.minorVersion}.${features.patchVersion}`;
653
621
  }
654
- getLabel() {
655
- var _a;
656
- return __awaiter(this, void 0, void 0, function* () {
657
- return (_a = (yield this.getFeatures(/*cached=*/ true)).label) !== null && _a !== void 0 ? _a : "";
658
- });
622
+ async getLabel() {
623
+ return (await this.getFeatures(/*cached=*/ true)).label ?? "";
659
624
  }
660
- isInitialized() {
661
- return __awaiter(this, void 0, void 0, function* () {
662
- return !!(yield this.getFeatures()).initialized;
663
- });
664
- }
665
- isLocked() {
666
- return __awaiter(this, void 0, void 0, function* () {
667
- const features = yield this.getFeatures();
668
- if (features.pinProtection && !features.pinCached)
669
- return true;
670
- if (features.passphraseProtection && !features.passphraseCached)
671
- return true;
672
- return false;
673
- });
625
+ async isInitialized() {
626
+ return !!(await this.getFeatures()).initialized;
674
627
  }
675
- getPublicKeys(getPublicKeys) {
676
- return __awaiter(this, void 0, void 0, function* () {
677
- const publicKeys = [];
678
- for (let i = 0; i < getPublicKeys.length; i++) {
679
- const { coin, addressNList, curve, showDisplay, scriptType } = getPublicKeys[i];
680
- const GPK = new Messages.GetPublicKey();
681
- if (coin)
682
- GPK.setCoinName(coin);
683
- GPK.setAddressNList(addressNList);
684
- GPK.setShowDisplay(showDisplay || false);
685
- GPK.setEcdsaCurveName(curve || "secp256k1");
686
- GPK.setScriptType((0, utils_1.translateInputScriptType)(scriptType || core.BTCInputScriptType.SpendAddress));
687
- const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETPUBLICKEY, GPK, {
688
- msgTimeout: showDisplay ? core.LONG_TIMEOUT : core.DEFAULT_TIMEOUT,
689
- });
690
- const publicKey = event.proto;
691
- publicKeys.push({ xpub: core.mustBeDefined(publicKey.getXpub()) });
692
- }
693
- return publicKeys;
694
- });
628
+ async isLocked() {
629
+ const features = await this.getFeatures();
630
+ if (features.pinProtection && !features.pinCached)
631
+ return true;
632
+ if (features.passphraseProtection && !features.passphraseCached)
633
+ return true;
634
+ return false;
695
635
  }
696
- ping(msg) {
697
- return __awaiter(this, void 0, void 0, function* () {
698
- const ping = new Messages.Ping();
699
- ping.setMessage(msg.msg);
700
- ping.setButtonProtection(msg.button || false);
701
- ping.setPinProtection(msg.pin || false);
702
- ping.setPassphraseProtection(msg.passphrase || false);
703
- const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_PING, ping, {
704
- msgTimeout: msg.button || msg.pin || msg.passphrase ? core.LONG_TIMEOUT : core.DEFAULT_TIMEOUT,
636
+ async getPublicKeys(getPublicKeys) {
637
+ const publicKeys = [];
638
+ for (let i = 0; i < getPublicKeys.length; i++) {
639
+ const { coin, addressNList, curve, showDisplay, scriptType } = getPublicKeys[i];
640
+ const GPK = new Messages.GetPublicKey();
641
+ if (coin)
642
+ GPK.setCoinName(coin);
643
+ GPK.setAddressNList(addressNList);
644
+ GPK.setShowDisplay(showDisplay || false);
645
+ GPK.setEcdsaCurveName(curve || "secp256k1");
646
+ GPK.setScriptType(translateInputScriptType(scriptType || core.BTCInputScriptType.SpendAddress));
647
+ const event = await this.transport.call(Messages.MessageType.MESSAGETYPE_GETPUBLICKEY, GPK, {
648
+ msgTimeout: showDisplay ? core.LONG_TIMEOUT : core.DEFAULT_TIMEOUT,
705
649
  });
706
- const message = event.proto;
707
- return { msg: core.mustBeDefined(message.getMessage()) };
650
+ const publicKey = event.proto;
651
+ publicKeys.push({ xpub: core.mustBeDefined(publicKey.getXpub()) });
652
+ }
653
+ return publicKeys;
654
+ }
655
+ async ping(msg) {
656
+ const ping = new Messages.Ping();
657
+ ping.setMessage(msg.msg);
658
+ ping.setButtonProtection(msg.button || false);
659
+ ping.setPinProtection(msg.pin || false);
660
+ ping.setPassphraseProtection(msg.passphrase || false);
661
+ const event = await this.transport.call(Messages.MessageType.MESSAGETYPE_PING, ping, {
662
+ msgTimeout: msg.button || msg.pin || msg.passphrase ? core.LONG_TIMEOUT : core.DEFAULT_TIMEOUT,
708
663
  });
709
- }
710
- reset(msg) {
711
- return __awaiter(this, void 0, void 0, function* () {
712
- const resetDevice = new Messages.ResetDevice();
713
- resetDevice.setStrength(msg.entropy || 128);
714
- resetDevice.setDisplayRandom(false);
715
- resetDevice.setPassphraseProtection(msg.passphrase || false);
716
- resetDevice.setPinProtection(msg.pin || false);
717
- resetDevice.setLabel(msg.label);
718
- if (msg.autoLockDelayMs) {
719
- resetDevice.setAutoLockDelayMs(msg.autoLockDelayMs);
720
- }
721
- resetDevice.setU2fCounter(msg.u2fCounter || Math.floor(+new Date() / 1000));
722
- // resetDevice.setWordsPerGape(wordsPerScreen) // Re-enable when patch gets in
723
- // Send
724
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_RESETDEVICE, resetDevice, {
725
- msgTimeout: core.LONG_TIMEOUT,
726
- });
727
- this.cacheFeatures(undefined);
664
+ const message = event.proto;
665
+ return { msg: core.mustBeDefined(message.getMessage()) };
666
+ }
667
+ async reset(msg) {
668
+ const resetDevice = new Messages.ResetDevice();
669
+ resetDevice.setStrength(msg.entropy || 128);
670
+ resetDevice.setDisplayRandom(false);
671
+ resetDevice.setPassphraseProtection(msg.passphrase || false);
672
+ resetDevice.setPinProtection(msg.pin || false);
673
+ resetDevice.setLabel(msg.label);
674
+ if (msg.autoLockDelayMs) {
675
+ resetDevice.setAutoLockDelayMs(msg.autoLockDelayMs);
676
+ }
677
+ resetDevice.setU2fCounter(msg.u2fCounter || Math.floor(+new Date() / 1000));
678
+ // resetDevice.setWordsPerGape(wordsPerScreen) // Re-enable when patch gets in
679
+ // Send
680
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_RESETDEVICE, resetDevice, {
681
+ msgTimeout: core.LONG_TIMEOUT,
728
682
  });
729
- }
730
- recover(r) {
731
- return __awaiter(this, void 0, void 0, function* () {
732
- const msg = new Messages.RecoveryDevice();
733
- msg.setWordCount({ 128: 12, 192: 18, 256: 24 }[r.entropy]);
734
- msg.setPassphraseProtection(r.passphrase);
735
- msg.setPinProtection(r.pin);
736
- msg.setLabel(r.label);
737
- msg.setLanguage(r.language || "english");
738
- msg.setEnforceWordlist(true);
739
- msg.setUseCharacterCipher(true);
740
- if (r.autoLockDelayMs) {
741
- msg.setAutoLockDelayMs(r.autoLockDelayMs);
742
- }
743
- msg.setU2fCounter(r.u2fCounter || Math.floor(+new Date() / 1000));
744
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_RECOVERYDEVICE, msg, {
745
- msgTimeout: core.LONG_TIMEOUT,
746
- });
747
- this.cacheFeatures(undefined);
683
+ this.cacheFeatures(undefined);
684
+ }
685
+ async recover(r) {
686
+ const msg = new Messages.RecoveryDevice();
687
+ msg.setWordCount({ 128: 12, 192: 18, 256: 24 }[r.entropy]);
688
+ msg.setPassphraseProtection(r.passphrase);
689
+ msg.setPinProtection(r.pin);
690
+ msg.setLabel(r.label);
691
+ msg.setLanguage(r.language || "english");
692
+ msg.setEnforceWordlist(true);
693
+ msg.setUseCharacterCipher(true);
694
+ if (r.autoLockDelayMs) {
695
+ msg.setAutoLockDelayMs(r.autoLockDelayMs);
696
+ }
697
+ msg.setU2fCounter(r.u2fCounter || Math.floor(+new Date() / 1000));
698
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_RECOVERYDEVICE, msg, {
699
+ msgTimeout: core.LONG_TIMEOUT,
748
700
  });
701
+ this.cacheFeatures(undefined);
749
702
  }
750
- pressYes() {
751
- return __awaiter(this, void 0, void 0, function* () {
752
- return this.press(true);
753
- });
703
+ async pressYes() {
704
+ return this.press(true);
754
705
  }
755
- pressNo() {
756
- return __awaiter(this, void 0, void 0, function* () {
757
- return this.press(false);
758
- });
706
+ async pressNo() {
707
+ return this.press(false);
759
708
  }
760
- press(isYes) {
761
- return __awaiter(this, void 0, void 0, function* () {
762
- const decision = new Messages.DebugLinkDecision();
763
- decision.setYesNo(isYes);
764
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_DEBUGLINKDECISION, decision, {
765
- noWait: true,
766
- debugLink: true,
767
- });
709
+ async press(isYes) {
710
+ const decision = new Messages.DebugLinkDecision();
711
+ decision.setYesNo(isYes);
712
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_DEBUGLINKDECISION, decision, {
713
+ noWait: true,
714
+ debugLink: true,
768
715
  });
769
716
  }
770
717
  hasOnDevicePinEntry() {
@@ -792,363 +739,295 @@ class KeepKeyHDWallet {
792
739
  supportsBroadcast() {
793
740
  return false;
794
741
  }
795
- sendPin(pin) {
796
- return __awaiter(this, void 0, void 0, function* () {
797
- const matrixAck = new Messages.PinMatrixAck();
798
- matrixAck.setPin(pin);
799
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_PINMATRIXACK, matrixAck, {
800
- msgTimeout: core.DEFAULT_TIMEOUT,
801
- omitLock: true,
802
- noWait: true,
803
- });
742
+ async sendPin(pin) {
743
+ const matrixAck = new Messages.PinMatrixAck();
744
+ matrixAck.setPin(pin);
745
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_PINMATRIXACK, matrixAck, {
746
+ msgTimeout: core.DEFAULT_TIMEOUT,
747
+ omitLock: true,
748
+ noWait: true,
804
749
  });
805
750
  }
806
- sendPassphrase(passphrase) {
807
- return __awaiter(this, void 0, void 0, function* () {
808
- const passphraseAck = new Messages.PassphraseAck();
809
- passphraseAck.setPassphrase(passphrase);
810
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_PASSPHRASEACK, passphraseAck, {
811
- msgTimeout: core.DEFAULT_TIMEOUT,
812
- omitLock: true,
813
- noWait: true,
814
- });
751
+ async sendPassphrase(passphrase) {
752
+ const passphraseAck = new Messages.PassphraseAck();
753
+ passphraseAck.setPassphrase(passphrase);
754
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_PASSPHRASEACK, passphraseAck, {
755
+ msgTimeout: core.DEFAULT_TIMEOUT,
756
+ omitLock: true,
757
+ noWait: true,
815
758
  });
816
759
  }
817
- sendCharacter(character) {
818
- return __awaiter(this, void 0, void 0, function* () {
819
- yield this.sendCharacterProto(character, false, false);
820
- });
760
+ async sendCharacter(character) {
761
+ await this.sendCharacterProto(character, false, false);
821
762
  }
822
- sendCharacterDelete() {
823
- return __awaiter(this, void 0, void 0, function* () {
824
- yield this.sendCharacterProto("", true, false);
825
- });
763
+ async sendCharacterDelete() {
764
+ await this.sendCharacterProto("", true, false);
826
765
  }
827
- sendCharacterDone() {
828
- return __awaiter(this, void 0, void 0, function* () {
829
- yield this.sendCharacterProto("", false, true);
830
- });
766
+ async sendCharacterDone() {
767
+ await this.sendCharacterProto("", false, true);
831
768
  }
832
769
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
833
- sendWord(word) {
834
- return __awaiter(this, void 0, void 0, function* () {
835
- throw new Error("Not Yet Implemented :(");
836
- });
770
+ async sendWord(word) {
771
+ throw new Error("Not Yet Implemented :(");
837
772
  }
838
- sendCharacterProto(character, _delete, _done) {
839
- return __awaiter(this, void 0, void 0, function* () {
840
- const characterAck = new Messages.CharacterAck();
841
- if (character !== "") {
842
- characterAck.setCharacter(character);
843
- }
844
- else if (_delete) {
845
- characterAck.setDelete(_delete);
846
- }
847
- else if (_done) {
848
- characterAck.setDone(_done);
849
- }
850
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_CHARACTERACK, characterAck, {
851
- msgTimeout: core.DEFAULT_TIMEOUT,
852
- omitLock: true,
853
- noWait: true,
854
- });
773
+ async sendCharacterProto(character, _delete, _done) {
774
+ const characterAck = new Messages.CharacterAck();
775
+ if (character !== "") {
776
+ characterAck.setCharacter(character);
777
+ }
778
+ else if (_delete) {
779
+ characterAck.setDelete(_delete);
780
+ }
781
+ else if (_done) {
782
+ characterAck.setDone(_done);
783
+ }
784
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_CHARACTERACK, characterAck, {
785
+ msgTimeout: core.DEFAULT_TIMEOUT,
786
+ omitLock: true,
787
+ noWait: true,
855
788
  });
856
789
  }
857
790
  // ApplyPolicy enables or disables a named policy such as "ShapeShift" on the device
858
- applyPolicy(p) {
859
- return __awaiter(this, void 0, void 0, function* () {
860
- const policy = new Types.PolicyType();
861
- policy.setPolicyName(p.policyName);
862
- policy.setEnabled(p.enabled);
863
- const applyPolicies = new Messages.ApplyPolicies();
864
- applyPolicies.setPolicyList([policy]);
865
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_APPLYPOLICIES, applyPolicies, {
866
- msgTimeout: core.LONG_TIMEOUT,
867
- });
868
- this.cacheFeatures(undefined);
791
+ async applyPolicy(p) {
792
+ const policy = new Types.PolicyType();
793
+ policy.setPolicyName(p.policyName);
794
+ policy.setEnabled(p.enabled);
795
+ const applyPolicies = new Messages.ApplyPolicies();
796
+ applyPolicies.setPolicyList([policy]);
797
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_APPLYPOLICIES, applyPolicies, {
798
+ msgTimeout: core.LONG_TIMEOUT,
869
799
  });
800
+ this.cacheFeatures(undefined);
870
801
  }
871
802
  // ApplySettings changes the label, language, and enabling/disabling the passphrase
872
803
  // The default language is english
873
- applySettings(s) {
874
- return __awaiter(this, void 0, void 0, function* () {
875
- const applySettings = new Messages.ApplySettings();
876
- if (s.label) {
877
- applySettings.setLabel(s.label);
878
- }
879
- if (s.language) {
880
- applySettings.setLanguage(s.language);
881
- }
882
- if (s.usePassphrase !== undefined) {
883
- applySettings.setUsePassphrase(s.usePassphrase);
884
- }
885
- if (s.autoLockDelayMs) {
886
- applySettings.setAutoLockDelayMs(s.autoLockDelayMs);
887
- }
888
- if (s.u2fCounter) {
889
- applySettings.setU2fCounter(s.u2fCounter);
890
- }
891
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_APPLYSETTINGS, applySettings);
892
- this.cacheFeatures(undefined);
893
- });
804
+ async applySettings(s) {
805
+ const applySettings = new Messages.ApplySettings();
806
+ if (s.label) {
807
+ applySettings.setLabel(s.label);
808
+ }
809
+ if (s.language) {
810
+ applySettings.setLanguage(s.language);
811
+ }
812
+ if (s.usePassphrase !== undefined) {
813
+ applySettings.setUsePassphrase(s.usePassphrase);
814
+ }
815
+ if (s.autoLockDelayMs) {
816
+ applySettings.setAutoLockDelayMs(s.autoLockDelayMs);
817
+ }
818
+ if (s.u2fCounter) {
819
+ applySettings.setU2fCounter(s.u2fCounter);
820
+ }
821
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_APPLYSETTINGS, applySettings);
822
+ this.cacheFeatures(undefined);
894
823
  }
895
824
  // Cancel aborts the last device action that required user interaction
896
825
  // It can follow a button request, passphrase request, or pin request
897
- cancel() {
898
- return __awaiter(this, void 0, void 0, function* () {
899
- yield this.transport.cancel();
900
- });
826
+ async cancel() {
827
+ await this.transport.cancel();
901
828
  }
902
829
  // ChangePin requests setting/changing the pin
903
- changePin() {
904
- return __awaiter(this, void 0, void 0, function* () {
905
- const changePin = new Messages.ChangePin();
906
- // User may be propmpted for button press up to 2 times
907
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_CHANGEPIN, changePin, {
908
- msgTimeout: core.LONG_TIMEOUT,
909
- });
830
+ async changePin() {
831
+ const changePin = new Messages.ChangePin();
832
+ // User may be propmpted for button press up to 2 times
833
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_CHANGEPIN, changePin, {
834
+ msgTimeout: core.LONG_TIMEOUT,
910
835
  });
911
836
  }
912
837
  // CipherKeyValue encrypts or decrypts a value with a given key, nodepath, and initializationVector
913
838
  // This method encrypts if encrypt is true and decrypts if false, the confirm paramater determines wether
914
839
  // the user is prompted on the device. See EncryptKeyValue() and DecryptKeyValue() for convenience methods
915
840
  // NOTE: If the length of the value in bytes is not divisible by 16 it will be zero padded
916
- cipherKeyValue(v) {
917
- return __awaiter(this, void 0, void 0, function* () {
918
- // if(val.length % 16 !== 0) val = val.concat() TODO THIS
919
- const cipherKeyValue = new Messages.CipherKeyValue();
920
- cipherKeyValue.setAddressNList(v.addressNList);
921
- cipherKeyValue.setKey(v.key);
922
- cipherKeyValue.setValue(v.value);
923
- cipherKeyValue.setEncrypt(!!v.encrypt);
924
- cipherKeyValue.setAskOnEncrypt(v.askOnEncrypt || false);
925
- cipherKeyValue.setAskOnDecrypt(v.askOnDecrypt || false);
926
- cipherKeyValue.setIv(v.iv || "");
927
- const response = yield this.transport.call(Messages.MessageType.MESSAGETYPE_CIPHERKEYVALUE, cipherKeyValue);
928
- const ckv = response.message;
929
- return ckv.getValue();
930
- });
841
+ async cipherKeyValue(v) {
842
+ // if(val.length % 16 !== 0) val = val.concat() TODO THIS
843
+ const cipherKeyValue = new Messages.CipherKeyValue();
844
+ cipherKeyValue.setAddressNList(v.addressNList);
845
+ cipherKeyValue.setKey(v.key);
846
+ cipherKeyValue.setValue(v.value);
847
+ cipherKeyValue.setEncrypt(!!v.encrypt);
848
+ cipherKeyValue.setAskOnEncrypt(v.askOnEncrypt || false);
849
+ cipherKeyValue.setAskOnDecrypt(v.askOnDecrypt || false);
850
+ cipherKeyValue.setIv(v.iv || "");
851
+ const response = await this.transport.call(Messages.MessageType.MESSAGETYPE_CIPHERKEYVALUE, cipherKeyValue);
852
+ const ckv = response.message;
853
+ return ckv.getValue();
931
854
  }
932
855
  // ClearSession clears cached session values such as the pin and passphrase
933
- clearSession() {
934
- return __awaiter(this, void 0, void 0, function* () {
935
- const clearSession = new Messages.ClearSession();
936
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_CLEARSESSION, clearSession);
937
- this.cacheFeatures(undefined);
938
- });
856
+ async clearSession() {
857
+ const clearSession = new Messages.ClearSession();
858
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_CLEARSESSION, clearSession);
859
+ this.cacheFeatures(undefined);
939
860
  }
940
861
  // DecryptKeyValue is a convenience method around decrypting with CipherKeyValue().
941
862
  // For more granular control of the process use CipherKeyValue()
942
- decryptKeyValue(v) {
943
- return __awaiter(this, void 0, void 0, function* () {
944
- return this.cipherKeyValue(v);
945
- });
863
+ async decryptKeyValue(v) {
864
+ return this.cipherKeyValue(v);
946
865
  }
947
866
  // FirmwareErase askes the device to erase its firmware
948
- firmwareErase() {
949
- return __awaiter(this, void 0, void 0, function* () {
950
- const firmwareErase = new Messages.FirmwareErase();
951
- // send
952
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_FIRMWAREERASE, firmwareErase);
953
- this.cacheFeatures(undefined);
954
- });
955
- }
956
- firmwareUpload(firmware) {
957
- return __awaiter(this, void 0, void 0, function* () {
958
- const firmwareUpload = new Messages.FirmwareUpload();
959
- const hash = yield this.transport.getFirmwareHash(firmware);
960
- firmwareUpload.setPayload(firmware);
961
- firmwareUpload.setPayloadHash(hash);
962
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_FIRMWAREUPLOAD, firmwareUpload);
963
- this.cacheFeatures(undefined);
964
- });
867
+ async firmwareErase() {
868
+ const firmwareErase = new Messages.FirmwareErase();
869
+ // send
870
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_FIRMWAREERASE, firmwareErase);
871
+ this.cacheFeatures(undefined);
872
+ }
873
+ async firmwareUpload(firmware) {
874
+ const firmwareUpload = new Messages.FirmwareUpload();
875
+ const hash = await this.transport.getFirmwareHash(firmware);
876
+ firmwareUpload.setPayload(firmware);
877
+ firmwareUpload.setPayloadHash(hash);
878
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_FIRMWAREUPLOAD, firmwareUpload);
879
+ this.cacheFeatures(undefined);
965
880
  }
966
881
  // Initialize assigns a hid connection to this KeepKey and send initialize message to device
967
- initialize() {
968
- return __awaiter(this, void 0, void 0, function* () {
969
- const initialize = new Messages.Initialize();
970
- const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_INITIALIZE, initialize);
971
- if (!event.message)
972
- throw event;
973
- const out = event.message;
974
- this.features = out;
975
- // v6.1.0 firmware changed usb serial numbers to match STM32 desig_device_id
976
- // If the deviceId in the features table doesn't match, then we need to
977
- // add another k-v pair to the keyring so it can be looked up either way.
978
- const transportDeviceID = yield this.transport.getDeviceID();
979
- if (out.deviceId && transportDeviceID !== out.deviceId) {
980
- this.transport.keyring.addAlias(transportDeviceID, out.deviceId);
981
- }
982
- const fwVersion = `v${out.majorVersion}.${out.minorVersion}.${out.patchVersion}`;
983
- //Lost Support per proto 44.3
984
- this._supportsOsmosis = semver_1.default.gte(fwVersion, "v7.7.0");
985
- this._supportsCosmos = semver_1.default.gte(fwVersion, "v7.3.0");
986
- this._supportsRipple = semver_1.default.gte(fwVersion, "v6.4.0");
987
- this._supportsBinance = semver_1.default.gte(fwVersion, "v6.4.0");
988
- this._supportsEos = semver_1.default.gte(fwVersion, "v6.4.0");
989
- // this._supportsThorchain = semver.get(fwVersion, "v7.3.0");
990
- this.cacheFeatures(out);
991
- return out;
992
- });
882
+ async initialize() {
883
+ const initialize = new Messages.Initialize();
884
+ const event = await this.transport.call(Messages.MessageType.MESSAGETYPE_INITIALIZE, initialize);
885
+ if (!event.message)
886
+ throw event;
887
+ const out = event.message;
888
+ this.features = out;
889
+ // v6.1.0 firmware changed usb serial numbers to match STM32 desig_device_id
890
+ // If the deviceId in the features table doesn't match, then we need to
891
+ // add another k-v pair to the keyring so it can be looked up either way.
892
+ const transportDeviceID = await this.transport.getDeviceID();
893
+ if (out.deviceId && transportDeviceID !== out.deviceId) {
894
+ this.transport.keyring.addAlias(transportDeviceID, out.deviceId);
895
+ }
896
+ const fwVersion = `v${out.majorVersion}.${out.minorVersion}.${out.patchVersion}`;
897
+ //Lost Support per proto 44.3
898
+ this._supportsOsmosis = semver.gte(fwVersion, "v7.7.0");
899
+ this._supportsCosmos = semver.gte(fwVersion, "v7.3.0");
900
+ this._supportsRipple = semver.gte(fwVersion, "v6.4.0");
901
+ this._supportsBinance = semver.gte(fwVersion, "v6.4.0");
902
+ this._supportsEos = semver.gte(fwVersion, "v6.4.0");
903
+ // this._supportsThorchain = semver.get(fwVersion, "v7.3.0");
904
+ this.cacheFeatures(out);
905
+ return out;
993
906
  }
994
907
  // GetFeatures returns the features and other device information such as the version, label, and supported coins
995
- getFeatures(cached = false) {
996
- return __awaiter(this, void 0, void 0, function* () {
997
- if (cached && this.featuresCache)
998
- return this.featuresCache;
999
- const features = new Messages.GetFeatures();
1000
- const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETFEATURES, features);
1001
- this.cacheFeatures(event.message);
1002
- return event.message;
1003
- });
908
+ async getFeatures(cached = false) {
909
+ if (cached && this.featuresCache)
910
+ return this.featuresCache;
911
+ const features = new Messages.GetFeatures();
912
+ const event = await this.transport.call(Messages.MessageType.MESSAGETYPE_GETFEATURES, features);
913
+ this.cacheFeatures(event.message);
914
+ return event.message;
1004
915
  }
1005
916
  cacheFeatures(features) {
1006
917
  this.featuresCache = features;
1007
918
  }
1008
919
  // GetEntropy requests sample data from the hardware RNG
1009
- getEntropy(size) {
1010
- return __awaiter(this, void 0, void 0, function* () {
1011
- const getEntropy = new Messages.GetEntropy();
1012
- getEntropy.setSize(size);
1013
- // send
1014
- const event = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETENTROPY, getEntropy, {
1015
- msgTimeout: core.LONG_TIMEOUT,
1016
- });
1017
- return core.mustBeDefined(event.proto).getEntropy_asU8();
920
+ async getEntropy(size) {
921
+ const getEntropy = new Messages.GetEntropy();
922
+ getEntropy.setSize(size);
923
+ // send
924
+ const event = await this.transport.call(Messages.MessageType.MESSAGETYPE_GETENTROPY, getEntropy, {
925
+ msgTimeout: core.LONG_TIMEOUT,
1018
926
  });
927
+ return core.mustBeDefined(event.proto).getEntropy_asU8();
1019
928
  }
1020
929
  // GetNumCoins returns the number of coins supported by the device regardless of if the hanve funds.
1021
- getNumCoins() {
1022
- return __awaiter(this, void 0, void 0, function* () {
1023
- const getCoinTable = new Messages.GetCoinTable();
1024
- const response = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETCOINTABLE, getCoinTable);
1025
- return core.mustBeDefined(core.mustBeDefined(response.proto).getNumCoins());
1026
- });
930
+ async getNumCoins() {
931
+ const getCoinTable = new Messages.GetCoinTable();
932
+ const response = await this.transport.call(Messages.MessageType.MESSAGETYPE_GETCOINTABLE, getCoinTable);
933
+ return core.mustBeDefined(core.mustBeDefined(response.proto).getNumCoins());
1027
934
  }
1028
935
  // GetCoinTable returns an array of Types.CoinTypes, with start and end arguments for paging.
1029
936
  // You cannot request more than 10 at a time.
1030
- getCoinTable(start = 0, end = start + 10) {
1031
- return __awaiter(this, void 0, void 0, function* () {
1032
- const getCoinTable = new Messages.GetCoinTable();
1033
- getCoinTable.setStart(start);
1034
- getCoinTable.setEnd(end);
1035
- const response = yield this.transport.call(Messages.MessageType.MESSAGETYPE_GETCOINTABLE, getCoinTable);
1036
- const coinTable = response.message;
1037
- return coinTable.tableList;
1038
- });
937
+ async getCoinTable(start = 0, end = start + 10) {
938
+ const getCoinTable = new Messages.GetCoinTable();
939
+ getCoinTable.setStart(start);
940
+ getCoinTable.setEnd(end);
941
+ const response = await this.transport.call(Messages.MessageType.MESSAGETYPE_GETCOINTABLE, getCoinTable);
942
+ const coinTable = response.message;
943
+ return coinTable.tableList;
1039
944
  }
1040
945
  // LoadDevice loads a provided seed onto the device and applies the provided settings
1041
946
  // including setting a pin/device label, enabling/disabling the passphrase, and whether to
1042
947
  // check the checksum of the provided mnemonic
1043
- loadDevice(msg) {
1044
- return __awaiter(this, void 0, void 0, function* () {
1045
- const loadDevice = new Messages.LoadDevice();
1046
- loadDevice.setMnemonic(msg.mnemonic);
1047
- loadDevice.setPassphraseProtection(!!msg.passphrase);
1048
- loadDevice.setSkipChecksum(!!msg.skipChecksum);
1049
- if (msg.pin)
1050
- loadDevice.setPin(msg.pin);
1051
- if (msg.label)
1052
- loadDevice.setLabel(msg.label);
1053
- // send
1054
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_LOADDEVICE, loadDevice, {
1055
- msgTimeout: core.LONG_TIMEOUT,
1056
- });
1057
- this.cacheFeatures(undefined);
948
+ async loadDevice(msg) {
949
+ const loadDevice = new Messages.LoadDevice();
950
+ loadDevice.setMnemonic(msg.mnemonic);
951
+ loadDevice.setPassphraseProtection(!!msg.passphrase);
952
+ loadDevice.setSkipChecksum(!!msg.skipChecksum);
953
+ if (msg.pin)
954
+ loadDevice.setPin(msg.pin);
955
+ if (msg.label)
956
+ loadDevice.setLabel(msg.label);
957
+ // send
958
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_LOADDEVICE, loadDevice, {
959
+ msgTimeout: core.LONG_TIMEOUT,
1058
960
  });
961
+ this.cacheFeatures(undefined);
1059
962
  }
1060
963
  // RemovePin disables pin protection for the device. If a pin is currently enabled
1061
964
  // it will prompt the user to enter the current pin
1062
- removePin() {
1063
- return __awaiter(this, void 0, void 0, function* () {
1064
- const changePin = new Messages.ChangePin();
1065
- changePin.setRemove(true);
1066
- // send
1067
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_CHANGEPIN, changePin);
1068
- this.cacheFeatures(undefined);
1069
- });
1070
- }
1071
- send(events) {
1072
- return __awaiter(this, void 0, void 0, function* () {
1073
- for (const event of events) {
1074
- const MessageType = typeRegistry_1.messageTypeRegistry[core.mustBeDefined(event.message_enum)];
1075
- const msg = new MessageType();
1076
- Object.entries(event.message).forEach(([key, value]) => {
1077
- const setterMethod = (0, utils_1.protoFieldToSetMethod)(key);
1078
- if (msg[setterMethod]) {
1079
- // Assume setter methods are always of the format: strength -> setStrength
1080
- // until this exists https://github.com/protocolbuffers/protobuf/issues/1591
1081
- msg[setterMethod](value);
1082
- }
1083
- });
1084
- yield this.transport.call(core.mustBeDefined(event.message_enum), msg);
1085
- }
1086
- });
965
+ async removePin() {
966
+ const changePin = new Messages.ChangePin();
967
+ changePin.setRemove(true);
968
+ // send
969
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_CHANGEPIN, changePin);
970
+ this.cacheFeatures(undefined);
971
+ }
972
+ async send(events) {
973
+ for (const event of events) {
974
+ const MessageType = messageTypeRegistry[core.mustBeDefined(event.message_enum)];
975
+ const msg = new MessageType();
976
+ Object.entries(event.message).forEach(([key, value]) => {
977
+ const setterMethod = protoFieldToSetMethod(key);
978
+ if (msg[setterMethod]) {
979
+ // Assume setter methods are always of the format: strength -> setStrength
980
+ // until this exists https://github.com/protocolbuffers/protobuf/issues/1591
981
+ msg[setterMethod](value);
982
+ }
983
+ });
984
+ await this.transport.call(core.mustBeDefined(event.message_enum), msg);
985
+ }
1087
986
  }
1088
987
  // SoftReset power cycles the device. The device only responds to
1089
988
  // this message while in manufacturer mode
1090
- softReset() {
1091
- return __awaiter(this, void 0, void 0, function* () {
1092
- const softReset = new Messages.SoftReset();
1093
- // send
1094
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_SOFTRESET, softReset);
1095
- this.cacheFeatures(undefined);
1096
- });
989
+ async softReset() {
990
+ const softReset = new Messages.SoftReset();
991
+ // send
992
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_SOFTRESET, softReset);
993
+ this.cacheFeatures(undefined);
1097
994
  }
1098
995
  // WipeDevice wipes all sensitive data and settings
1099
- wipe() {
1100
- return __awaiter(this, void 0, void 0, function* () {
1101
- const wipeDevice = new Messages.WipeDevice();
1102
- // send
1103
- yield this.transport.call(Messages.MessageType.MESSAGETYPE_WIPEDEVICE, wipeDevice);
1104
- this.cacheFeatures(undefined);
1105
- });
996
+ async wipe() {
997
+ const wipeDevice = new Messages.WipeDevice();
998
+ // send
999
+ await this.transport.call(Messages.MessageType.MESSAGETYPE_WIPEDEVICE, wipeDevice);
1000
+ this.cacheFeatures(undefined);
1106
1001
  }
1107
- btcSupportsCoin(coin) {
1108
- return __awaiter(this, void 0, void 0, function* () {
1109
- return this.info.btcSupportsCoin(coin);
1110
- });
1002
+ async btcSupportsCoin(coin) {
1003
+ return this.info.btcSupportsCoin(coin);
1111
1004
  }
1112
- btcSupportsScriptType(coin, scriptType) {
1113
- return __awaiter(this, void 0, void 0, function* () {
1114
- return this.info.btcSupportsScriptType(coin, scriptType);
1115
- });
1005
+ async btcSupportsScriptType(coin, scriptType) {
1006
+ return this.info.btcSupportsScriptType(coin, scriptType);
1116
1007
  }
1117
- btcGetAddress(msg) {
1118
- return __awaiter(this, void 0, void 0, function* () {
1119
- return Btc.btcGetAddress(this, this.transport, msg);
1120
- });
1008
+ async btcGetAddress(msg) {
1009
+ return Btc.btcGetAddress(this, this.transport, msg);
1121
1010
  }
1122
- btcSignTx(msg) {
1123
- return __awaiter(this, void 0, void 0, function* () {
1124
- return Btc.btcSignTx(this, this.transport, msg);
1125
- });
1011
+ async btcSignTx(msg) {
1012
+ return Btc.btcSignTx(this, this.transport, msg);
1126
1013
  }
1127
- btcSupportsSecureTransfer() {
1128
- return __awaiter(this, void 0, void 0, function* () {
1129
- return this.info.btcSupportsSecureTransfer();
1130
- });
1014
+ async btcSupportsSecureTransfer() {
1015
+ return this.info.btcSupportsSecureTransfer();
1131
1016
  }
1132
1017
  btcSupportsNativeShapeShift() {
1133
1018
  return this.info.btcSupportsNativeShapeShift();
1134
1019
  }
1135
- ethSupportsEIP1559() {
1136
- return __awaiter(this, void 0, void 0, function* () {
1137
- // EIP1559 support starts in v7.2.1
1138
- // return semver.gte(await this.getFirmwareVersion(), "v7.2.1");
1139
- // disable EIP1559 support until edge case fail states are fixed across all evm chains
1140
- return false;
1141
- });
1020
+ async ethSupportsEIP1559() {
1021
+ // EIP1559 support starts in v7.2.1
1022
+ // return semver.gte(await this.getFirmwareVersion(), "v7.2.1");
1023
+ // disable EIP1559 support until edge case fail states are fixed across all evm chains
1024
+ return false;
1142
1025
  }
1143
- btcSignMessage(msg) {
1144
- return __awaiter(this, void 0, void 0, function* () {
1145
- return Btc.btcSignMessage(this, this.transport, msg);
1146
- });
1026
+ async btcSignMessage(msg) {
1027
+ return Btc.btcSignMessage(this, this.transport, msg);
1147
1028
  }
1148
- btcVerifyMessage(msg) {
1149
- return __awaiter(this, void 0, void 0, function* () {
1150
- return Btc.btcVerifyMessage(this, this.transport, msg);
1151
- });
1029
+ async btcVerifyMessage(msg) {
1030
+ return Btc.btcVerifyMessage(this, this.transport, msg);
1152
1031
  }
1153
1032
  btcGetAccountPaths(msg) {
1154
1033
  return this.info.btcGetAccountPaths(msg);
@@ -1160,40 +1039,26 @@ class KeepKeyHDWallet {
1160
1039
  // return false
1161
1040
  return this.info.btcIsSameAccount(msg);
1162
1041
  }
1163
- ethSignTx(msg) {
1164
- return __awaiter(this, void 0, void 0, function* () {
1165
- return Eth.ethSignTx(this.transport, msg);
1166
- });
1042
+ async ethSignTx(msg) {
1043
+ return Eth.ethSignTx(this.transport, msg);
1167
1044
  }
1168
- ethGetAddress(msg) {
1169
- return __awaiter(this, void 0, void 0, function* () {
1170
- return Eth.ethGetAddress(this.transport, msg);
1171
- });
1045
+ async ethGetAddress(msg) {
1046
+ return Eth.ethGetAddress(this.transport, msg);
1172
1047
  }
1173
- ethSignMessage(msg) {
1174
- return __awaiter(this, void 0, void 0, function* () {
1175
- return Eth.ethSignMessage(this.transport, msg);
1176
- });
1048
+ async ethSignMessage(msg) {
1049
+ return Eth.ethSignMessage(this.transport, msg);
1177
1050
  }
1178
- ethSignTypedData(msg) {
1179
- return __awaiter(this, void 0, void 0, function* () {
1180
- return Eth.ethSignTypedData(this.transport, msg);
1181
- });
1051
+ async ethSignTypedData(msg) {
1052
+ return Eth.ethSignTypedData(this.transport, msg);
1182
1053
  }
1183
- ethVerifyMessage(msg) {
1184
- return __awaiter(this, void 0, void 0, function* () {
1185
- return Eth.ethVerifyMessage(this.transport, msg);
1186
- });
1054
+ async ethVerifyMessage(msg) {
1055
+ return Eth.ethVerifyMessage(this.transport, msg);
1187
1056
  }
1188
- ethSupportsNetwork(chain_id) {
1189
- return __awaiter(this, void 0, void 0, function* () {
1190
- return this.info.ethSupportsNetwork(chain_id);
1191
- });
1057
+ async ethSupportsNetwork(chain_id) {
1058
+ return this.info.ethSupportsNetwork(chain_id);
1192
1059
  }
1193
- ethSupportsSecureTransfer() {
1194
- return __awaiter(this, void 0, void 0, function* () {
1195
- return this.info.ethSupportsSecureTransfer();
1196
- });
1060
+ async ethSupportsSecureTransfer() {
1061
+ return this.info.ethSupportsSecureTransfer();
1197
1062
  }
1198
1063
  ethSupportsNativeShapeShift() {
1199
1064
  return this.info.ethSupportsNativeShapeShift();
@@ -1283,13 +1148,10 @@ class KeepKeyHDWallet {
1283
1148
  return this.info.binanceNextAccountPath(msg);
1284
1149
  }
1285
1150
  }
1286
- exports.KeepKeyHDWallet = KeepKeyHDWallet;
1287
- function info() {
1151
+ export function info() {
1288
1152
  return new KeepKeyHDWalletInfo();
1289
1153
  }
1290
- exports.info = info;
1291
- function create(transport) {
1154
+ export function create(transport) {
1292
1155
  return new KeepKeyHDWallet(transport);
1293
1156
  }
1294
- exports.create = create;
1295
1157
  //# sourceMappingURL=keepkey.js.map