@shapeshiftoss/hdwallet-keepkey 1.55.3 → 1.55.4

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