@onekeyfe/hd-web-sdk 0.1.19 → 0.1.20

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.
@@ -14925,6 +14925,11 @@ class Device extends events.exports {
14925
14925
  }
14926
14926
  } catch (error) {
14927
14927
  this.runPromise = null;
14928
+
14929
+ if (error instanceof hdShared.HardwareError) {
14930
+ return Promise.reject(error);
14931
+ }
14932
+
14928
14933
  return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, `Initialize failed: ${error.message}, code: ${error.code}`));
14929
14934
  }
14930
14935
  }
@@ -15196,16 +15201,13 @@ class BaseMethod {
15196
15201
  checkFirmwareRelease() {
15197
15202
  if (!this.device || !this.device.features) return;
15198
15203
  const releaseInfo = getFirmwareReleaseInfo(this.device.features);
15199
-
15200
- if (['outdated', 'required'].includes(releaseInfo.status)) {
15201
- this.postMessage(createFirmwareMessage(FIRMWARE.RELEASE_INFO, releaseInfo));
15202
- }
15203
-
15204
+ this.postMessage(createFirmwareMessage(FIRMWARE.RELEASE_INFO, Object.assign(Object.assign({}, releaseInfo), {
15205
+ features: this.device.features
15206
+ })));
15204
15207
  const bleReleaseInfo = getBleFirmwareReleaseInfo(this.device.features);
15205
-
15206
- if (['outdated', 'required'].includes(bleReleaseInfo.status)) {
15207
- this.postMessage(createFirmwareMessage(FIRMWARE.BLE_RELEASE_INFO, bleReleaseInfo));
15208
- }
15208
+ this.postMessage(createFirmwareMessage(FIRMWARE.BLE_RELEASE_INFO, Object.assign(Object.assign({}, bleReleaseInfo), {
15209
+ features: this.device.features
15210
+ })));
15209
15211
  }
15210
15212
 
15211
15213
  dispose() {}
@@ -15404,6 +15406,7 @@ class CipherKeyValue extends BaseMethod {
15404
15406
  init() {
15405
15407
  var _a;
15406
15408
 
15409
+ this.checkDeviceId = true;
15407
15410
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15408
15411
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
15409
15412
  const payload = this.hasBundle ? this.payload : {
@@ -15681,6 +15684,7 @@ class BTCGetAddress extends BaseMethod {
15681
15684
  }
15682
15685
 
15683
15686
  init() {
15687
+ this.checkDeviceId = true;
15684
15688
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15685
15689
  this.hasBundle = Object.prototype.hasOwnProperty.call(this.payload, 'bundle');
15686
15690
  const payload = this.hasBundle ? this.payload : {
@@ -15764,6 +15768,7 @@ class BTCGetPublicKey extends BaseMethod {
15764
15768
  }
15765
15769
 
15766
15770
  init() {
15771
+ this.checkDeviceId = true;
15767
15772
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15768
15773
  this.hasBundle = Object.prototype.hasOwnProperty.call(this.payload, 'bundle');
15769
15774
  const payload = this.hasBundle ? this.payload : {
@@ -15838,6 +15843,7 @@ class BTCGetPublicKey extends BaseMethod {
15838
15843
 
15839
15844
  class BTCSignMessage extends BaseMethod {
15840
15845
  init() {
15846
+ this.checkDeviceId = true;
15841
15847
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15842
15848
  validateParams(this.payload, [{
15843
15849
  name: 'path',
@@ -16314,6 +16320,7 @@ var signtxLegacy = (typedCall, inputs, outputs, refTxsArray, options, coinName)
16314
16320
 
16315
16321
  class BTCSignTransaction extends BaseMethod {
16316
16322
  init() {
16323
+ this.checkDeviceId = true;
16317
16324
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16318
16325
  validateParams(this.payload, [{
16319
16326
  name: 'coin',
@@ -16488,6 +16495,7 @@ class BTCSignTransaction extends BaseMethod {
16488
16495
 
16489
16496
  class BTCVerifyMessage extends BaseMethod {
16490
16497
  init() {
16498
+ this.checkDeviceId = true;
16491
16499
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16492
16500
  validateParams(this.payload, [{
16493
16501
  name: 'address',
@@ -16916,6 +16924,7 @@ class EvmGetAddress extends BaseMethod {
16916
16924
  init() {
16917
16925
  var _a;
16918
16926
 
16927
+ this.checkDeviceId = true;
16919
16928
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16920
16929
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
16921
16930
  const payload = this.hasBundle ? this.payload : {
@@ -16976,6 +16985,7 @@ class EVMGetPublicKey extends BaseMethod {
16976
16985
  init() {
16977
16986
  var _a;
16978
16987
 
16988
+ this.checkDeviceId = true;
16979
16989
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16980
16990
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
16981
16991
  const payload = this.hasBundle ? this.payload : {
@@ -17025,6 +17035,7 @@ class EVMGetPublicKey extends BaseMethod {
17025
17035
 
17026
17036
  class EVMSignMessage$2 extends BaseMethod {
17027
17037
  init() {
17038
+ this.checkDeviceId = true;
17028
17039
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17029
17040
  validateParams(this.payload, [{
17030
17041
  name: 'path',
@@ -17056,6 +17067,7 @@ class EVMSignMessage$2 extends BaseMethod {
17056
17067
 
17057
17068
  class EVMSignMessageEIP712 extends BaseMethod {
17058
17069
  init() {
17070
+ this.checkDeviceId = true;
17059
17071
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17060
17072
  validateParams(this.payload, [{
17061
17073
  name: 'path',
@@ -17219,6 +17231,7 @@ class EVMSignTransaction extends BaseMethod {
17219
17231
  }
17220
17232
 
17221
17233
  init() {
17234
+ this.checkDeviceId = true;
17222
17235
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17223
17236
  validateParams(this.payload, [{
17224
17237
  name: 'path',
@@ -17460,6 +17473,7 @@ const getFieldType = (typeName, types) => {
17460
17473
 
17461
17474
  class EVMSignTypedData extends BaseMethod {
17462
17475
  init() {
17476
+ this.checkDeviceId = true;
17463
17477
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17464
17478
  validateParams(this.payload, [{
17465
17479
  name: 'path',
@@ -17683,6 +17697,7 @@ class EVMSignTypedData extends BaseMethod {
17683
17697
 
17684
17698
  class EVMSignMessage$1 extends BaseMethod {
17685
17699
  init() {
17700
+ this.checkDeviceId = true;
17686
17701
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17687
17702
  validateParams(this.payload, [{
17688
17703
  name: 'address',
@@ -17727,6 +17742,7 @@ class StarcoinGetAddress extends BaseMethod {
17727
17742
  init() {
17728
17743
  var _a;
17729
17744
 
17745
+ this.checkDeviceId = true;
17730
17746
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17731
17747
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17732
17748
  const payload = this.hasBundle ? this.payload : {
@@ -17783,6 +17799,7 @@ class StarcoinGetPublicKey extends BaseMethod {
17783
17799
  init() {
17784
17800
  var _a;
17785
17801
 
17802
+ this.checkDeviceId = true;
17786
17803
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17787
17804
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17788
17805
  const payload = this.hasBundle ? this.payload : {
@@ -17832,6 +17849,7 @@ class StarcoinGetPublicKey extends BaseMethod {
17832
17849
 
17833
17850
  class StarcoinSignMessage extends BaseMethod {
17834
17851
  init() {
17852
+ this.checkDeviceId = true;
17835
17853
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17836
17854
  validateParams(this.payload, [{
17837
17855
  name: 'path',
@@ -17863,6 +17881,7 @@ class StarcoinSignMessage extends BaseMethod {
17863
17881
 
17864
17882
  class StarcoinSignTransaction extends BaseMethod {
17865
17883
  init() {
17884
+ this.checkDeviceId = true;
17866
17885
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17867
17886
  validateParams(this.payload, [{
17868
17887
  name: 'path',
@@ -17894,6 +17913,7 @@ class StarcoinSignTransaction extends BaseMethod {
17894
17913
 
17895
17914
  class EVMSignMessage extends BaseMethod {
17896
17915
  init() {
17916
+ this.checkDeviceId = true;
17897
17917
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17898
17918
  validateParams(this.payload, [{
17899
17919
  name: 'publicKey',
@@ -17940,6 +17960,7 @@ class NEMGetAddress extends BaseMethod {
17940
17960
  init() {
17941
17961
  var _a;
17942
17962
 
17963
+ this.checkDeviceId = true;
17943
17964
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17944
17965
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17945
17966
  const payload = this.hasBundle ? this.payload : {
@@ -18193,6 +18214,7 @@ class NEMSignTransaction extends BaseMethod {
18193
18214
  }
18194
18215
 
18195
18216
  init() {
18217
+ this.checkDeviceId = true;
18196
18218
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18197
18219
  validateParams(this.payload, [{
18198
18220
  name: 'path',
@@ -18228,6 +18250,7 @@ class SolGetAddress extends BaseMethod {
18228
18250
  init() {
18229
18251
  var _a;
18230
18252
 
18253
+ this.checkDeviceId = true;
18231
18254
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18232
18255
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
18233
18256
  const payload = this.hasBundle ? this.payload : {
@@ -18288,6 +18311,7 @@ class SolSignTransaction extends BaseMethod {
18288
18311
  init() {
18289
18312
  var _a;
18290
18313
 
18314
+ this.checkDeviceId = true;
18291
18315
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18292
18316
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
18293
18317
  const payload = this.hasBundle ? this.payload : {
@@ -18357,6 +18381,7 @@ class StellarGetAddress extends BaseMethod {
18357
18381
  init() {
18358
18382
  var _a;
18359
18383
 
18384
+ this.checkDeviceId = true;
18360
18385
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18361
18386
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
18362
18387
  const payload = this.hasBundle ? this.payload : {
@@ -18593,6 +18618,7 @@ class StellarSignTransaction extends BaseMethod {
18593
18618
  }
18594
18619
 
18595
18620
  init() {
18621
+ this.checkDeviceId = true;
18596
18622
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18597
18623
  validateParams(this.payload, [{
18598
18624
  name: 'path',
@@ -19156,9 +19182,7 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
19156
19182
  Log.debug('Call API - setDevice: ', device.mainId);
19157
19183
  (_a = method.setDevice) === null || _a === void 0 ? void 0 : _a.call(method, device);
19158
19184
  device.on(DEVICE.PIN, onDevicePinHandler);
19159
- device.on(DEVICE.BUTTON, (d, code) => {
19160
- onDeviceButtonHandler(d, code);
19161
- });
19185
+ device.on(DEVICE.BUTTON, onDeviceButtonHandler);
19162
19186
  device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
19163
19187
 
19164
19188
  try {
@@ -19257,6 +19281,7 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
19257
19281
 
19258
19282
  closePopup();
19259
19283
  cleanup();
19284
+ removeDeviceListener(device);
19260
19285
  }
19261
19286
  });
19262
19287
 
@@ -19359,7 +19384,8 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
19359
19384
  } catch (error) {
19360
19385
  Log.debug('device list error: ', error);
19361
19386
 
19362
- if (error.errorCode === hdShared.HardwareErrorCode.BridgeNotInstalled) {
19387
+ if ([hdShared.HardwareErrorCode.BridgeNotInstalled, hdShared.HardwareErrorCode.BridgeTimeoutError].includes(error.errorCode)) {
19388
+ _deviceList = undefined;
19363
19389
  reject(error);
19364
19390
  return;
19365
19391
  }
@@ -19451,6 +19477,12 @@ const cleanup = () => {
19451
19477
  Log.debug('Cleanup...');
19452
19478
  };
19453
19479
 
19480
+ const removeDeviceListener = device => {
19481
+ device.removeListener(DEVICE.PIN, onDevicePinHandler);
19482
+ device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
19483
+ device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
19484
+ };
19485
+
19454
19486
  const closePopup = () => {
19455
19487
  postMessage(createUiMessage(UI_REQUEST$1.CLOSE_UI_WINDOW));
19456
19488
  };
@@ -46124,7 +46156,7 @@ const src_init = async settings => {
46124
46156
 
46125
46157
  try {
46126
46158
  await init({ ..._settings,
46127
- version: "0.1.19"
46159
+ version: "0.1.20"
46128
46160
  });
46129
46161
  return true;
46130
46162
  } catch (e) {