@onekeyfe/hd-web-sdk 0.1.19 → 0.1.22

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.
@@ -14531,9 +14531,7 @@ class DeviceCommands {
14531
14531
  }
14532
14532
 
14533
14533
  if (res.type === 'PassphraseRequest') {
14534
- return this._commonCall('PassphraseAck', {
14535
- passphrase: ''
14536
- });
14534
+ return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportPassphrase));
14537
14535
  }
14538
14536
 
14539
14537
  if (res.type === 'Deprecated_PassphraseStateRequest') ;
@@ -14925,6 +14923,11 @@ class Device extends events.exports {
14925
14923
  }
14926
14924
  } catch (error) {
14927
14925
  this.runPromise = null;
14926
+
14927
+ if (error instanceof hdShared.HardwareError) {
14928
+ return Promise.reject(error);
14929
+ }
14930
+
14928
14931
  return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceInitializeFailed, `Initialize failed: ${error.message}, code: ${error.code}`));
14929
14932
  }
14930
14933
  }
@@ -15196,16 +15199,13 @@ class BaseMethod {
15196
15199
  checkFirmwareRelease() {
15197
15200
  if (!this.device || !this.device.features) return;
15198
15201
  const releaseInfo = getFirmwareReleaseInfo(this.device.features);
15199
-
15200
- if (['outdated', 'required'].includes(releaseInfo.status)) {
15201
- this.postMessage(createFirmwareMessage(FIRMWARE.RELEASE_INFO, releaseInfo));
15202
- }
15203
-
15202
+ this.postMessage(createFirmwareMessage(FIRMWARE.RELEASE_INFO, Object.assign(Object.assign({}, releaseInfo), {
15203
+ features: this.device.features
15204
+ })));
15204
15205
  const bleReleaseInfo = getBleFirmwareReleaseInfo(this.device.features);
15205
-
15206
- if (['outdated', 'required'].includes(bleReleaseInfo.status)) {
15207
- this.postMessage(createFirmwareMessage(FIRMWARE.BLE_RELEASE_INFO, bleReleaseInfo));
15208
- }
15206
+ this.postMessage(createFirmwareMessage(FIRMWARE.BLE_RELEASE_INFO, Object.assign(Object.assign({}, bleReleaseInfo), {
15207
+ features: this.device.features
15208
+ })));
15209
15209
  }
15210
15210
 
15211
15211
  dispose() {}
@@ -15404,6 +15404,7 @@ class CipherKeyValue extends BaseMethod {
15404
15404
  init() {
15405
15405
  var _a;
15406
15406
 
15407
+ this.checkDeviceId = true;
15407
15408
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15408
15409
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
15409
15410
  const payload = this.hasBundle ? this.payload : {
@@ -15681,6 +15682,7 @@ class BTCGetAddress extends BaseMethod {
15681
15682
  }
15682
15683
 
15683
15684
  init() {
15685
+ this.checkDeviceId = true;
15684
15686
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15685
15687
  this.hasBundle = Object.prototype.hasOwnProperty.call(this.payload, 'bundle');
15686
15688
  const payload = this.hasBundle ? this.payload : {
@@ -15764,6 +15766,7 @@ class BTCGetPublicKey extends BaseMethod {
15764
15766
  }
15765
15767
 
15766
15768
  init() {
15769
+ this.checkDeviceId = true;
15767
15770
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15768
15771
  this.hasBundle = Object.prototype.hasOwnProperty.call(this.payload, 'bundle');
15769
15772
  const payload = this.hasBundle ? this.payload : {
@@ -15838,6 +15841,7 @@ class BTCGetPublicKey extends BaseMethod {
15838
15841
 
15839
15842
  class BTCSignMessage extends BaseMethod {
15840
15843
  init() {
15844
+ this.checkDeviceId = true;
15841
15845
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
15842
15846
  validateParams(this.payload, [{
15843
15847
  name: 'path',
@@ -16314,6 +16318,7 @@ var signtxLegacy = (typedCall, inputs, outputs, refTxsArray, options, coinName)
16314
16318
 
16315
16319
  class BTCSignTransaction extends BaseMethod {
16316
16320
  init() {
16321
+ this.checkDeviceId = true;
16317
16322
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16318
16323
  validateParams(this.payload, [{
16319
16324
  name: 'coin',
@@ -16488,6 +16493,7 @@ class BTCSignTransaction extends BaseMethod {
16488
16493
 
16489
16494
  class BTCVerifyMessage extends BaseMethod {
16490
16495
  init() {
16496
+ this.checkDeviceId = true;
16491
16497
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16492
16498
  validateParams(this.payload, [{
16493
16499
  name: 'address',
@@ -16916,6 +16922,7 @@ class EvmGetAddress extends BaseMethod {
16916
16922
  init() {
16917
16923
  var _a;
16918
16924
 
16925
+ this.checkDeviceId = true;
16919
16926
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16920
16927
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
16921
16928
  const payload = this.hasBundle ? this.payload : {
@@ -16976,6 +16983,7 @@ class EVMGetPublicKey extends BaseMethod {
16976
16983
  init() {
16977
16984
  var _a;
16978
16985
 
16986
+ this.checkDeviceId = true;
16979
16987
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
16980
16988
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
16981
16989
  const payload = this.hasBundle ? this.payload : {
@@ -17025,6 +17033,7 @@ class EVMGetPublicKey extends BaseMethod {
17025
17033
 
17026
17034
  class EVMSignMessage$2 extends BaseMethod {
17027
17035
  init() {
17036
+ this.checkDeviceId = true;
17028
17037
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17029
17038
  validateParams(this.payload, [{
17030
17039
  name: 'path',
@@ -17056,6 +17065,7 @@ class EVMSignMessage$2 extends BaseMethod {
17056
17065
 
17057
17066
  class EVMSignMessageEIP712 extends BaseMethod {
17058
17067
  init() {
17068
+ this.checkDeviceId = true;
17059
17069
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17060
17070
  validateParams(this.payload, [{
17061
17071
  name: 'path',
@@ -17219,6 +17229,7 @@ class EVMSignTransaction extends BaseMethod {
17219
17229
  }
17220
17230
 
17221
17231
  init() {
17232
+ this.checkDeviceId = true;
17222
17233
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17223
17234
  validateParams(this.payload, [{
17224
17235
  name: 'path',
@@ -17460,6 +17471,7 @@ const getFieldType = (typeName, types) => {
17460
17471
 
17461
17472
  class EVMSignTypedData extends BaseMethod {
17462
17473
  init() {
17474
+ this.checkDeviceId = true;
17463
17475
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17464
17476
  validateParams(this.payload, [{
17465
17477
  name: 'path',
@@ -17683,6 +17695,7 @@ class EVMSignTypedData extends BaseMethod {
17683
17695
 
17684
17696
  class EVMSignMessage$1 extends BaseMethod {
17685
17697
  init() {
17698
+ this.checkDeviceId = true;
17686
17699
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17687
17700
  validateParams(this.payload, [{
17688
17701
  name: 'address',
@@ -17727,6 +17740,7 @@ class StarcoinGetAddress extends BaseMethod {
17727
17740
  init() {
17728
17741
  var _a;
17729
17742
 
17743
+ this.checkDeviceId = true;
17730
17744
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17731
17745
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17732
17746
  const payload = this.hasBundle ? this.payload : {
@@ -17783,6 +17797,7 @@ class StarcoinGetPublicKey extends BaseMethod {
17783
17797
  init() {
17784
17798
  var _a;
17785
17799
 
17800
+ this.checkDeviceId = true;
17786
17801
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17787
17802
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17788
17803
  const payload = this.hasBundle ? this.payload : {
@@ -17832,6 +17847,7 @@ class StarcoinGetPublicKey extends BaseMethod {
17832
17847
 
17833
17848
  class StarcoinSignMessage extends BaseMethod {
17834
17849
  init() {
17850
+ this.checkDeviceId = true;
17835
17851
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17836
17852
  validateParams(this.payload, [{
17837
17853
  name: 'path',
@@ -17863,6 +17879,7 @@ class StarcoinSignMessage extends BaseMethod {
17863
17879
 
17864
17880
  class StarcoinSignTransaction extends BaseMethod {
17865
17881
  init() {
17882
+ this.checkDeviceId = true;
17866
17883
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17867
17884
  validateParams(this.payload, [{
17868
17885
  name: 'path',
@@ -17894,6 +17911,7 @@ class StarcoinSignTransaction extends BaseMethod {
17894
17911
 
17895
17912
  class EVMSignMessage extends BaseMethod {
17896
17913
  init() {
17914
+ this.checkDeviceId = true;
17897
17915
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17898
17916
  validateParams(this.payload, [{
17899
17917
  name: 'publicKey',
@@ -17940,6 +17958,7 @@ class NEMGetAddress extends BaseMethod {
17940
17958
  init() {
17941
17959
  var _a;
17942
17960
 
17961
+ this.checkDeviceId = true;
17943
17962
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
17944
17963
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
17945
17964
  const payload = this.hasBundle ? this.payload : {
@@ -18193,6 +18212,7 @@ class NEMSignTransaction extends BaseMethod {
18193
18212
  }
18194
18213
 
18195
18214
  init() {
18215
+ this.checkDeviceId = true;
18196
18216
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18197
18217
  validateParams(this.payload, [{
18198
18218
  name: 'path',
@@ -18228,6 +18248,7 @@ class SolGetAddress extends BaseMethod {
18228
18248
  init() {
18229
18249
  var _a;
18230
18250
 
18251
+ this.checkDeviceId = true;
18231
18252
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18232
18253
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
18233
18254
  const payload = this.hasBundle ? this.payload : {
@@ -18288,6 +18309,7 @@ class SolSignTransaction extends BaseMethod {
18288
18309
  init() {
18289
18310
  var _a;
18290
18311
 
18312
+ this.checkDeviceId = true;
18291
18313
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18292
18314
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
18293
18315
  const payload = this.hasBundle ? this.payload : {
@@ -18357,6 +18379,7 @@ class StellarGetAddress extends BaseMethod {
18357
18379
  init() {
18358
18380
  var _a;
18359
18381
 
18382
+ this.checkDeviceId = true;
18360
18383
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18361
18384
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
18362
18385
  const payload = this.hasBundle ? this.payload : {
@@ -18593,6 +18616,7 @@ class StellarSignTransaction extends BaseMethod {
18593
18616
  }
18594
18617
 
18595
18618
  init() {
18619
+ this.checkDeviceId = true;
18596
18620
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.INITIALIZE];
18597
18621
  validateParams(this.payload, [{
18598
18622
  name: 'path',
@@ -19156,9 +19180,7 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
19156
19180
  Log.debug('Call API - setDevice: ', device.mainId);
19157
19181
  (_a = method.setDevice) === null || _a === void 0 ? void 0 : _a.call(method, device);
19158
19182
  device.on(DEVICE.PIN, onDevicePinHandler);
19159
- device.on(DEVICE.BUTTON, (d, code) => {
19160
- onDeviceButtonHandler(d, code);
19161
- });
19183
+ device.on(DEVICE.BUTTON, onDeviceButtonHandler);
19162
19184
  device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
19163
19185
 
19164
19186
  try {
@@ -19257,6 +19279,7 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
19257
19279
 
19258
19280
  closePopup();
19259
19281
  cleanup();
19282
+ removeDeviceListener(device);
19260
19283
  }
19261
19284
  });
19262
19285
 
@@ -19359,7 +19382,8 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
19359
19382
  } catch (error) {
19360
19383
  Log.debug('device list error: ', error);
19361
19384
 
19362
- if (error.errorCode === hdShared.HardwareErrorCode.BridgeNotInstalled) {
19385
+ if ([hdShared.HardwareErrorCode.BridgeNotInstalled, hdShared.HardwareErrorCode.BridgeTimeoutError].includes(error.errorCode)) {
19386
+ _deviceList = undefined;
19363
19387
  reject(error);
19364
19388
  return;
19365
19389
  }
@@ -19395,7 +19419,7 @@ const ensureConnected = (method, pollingId) => __awaiter(void 0, void 0, void 0,
19395
19419
  } catch (error) {
19396
19420
  Log.debug('device error: ', error);
19397
19421
 
19398
- if (error.errorCode === hdShared.HardwareErrorCode.BlePermissionError) {
19422
+ if ([hdShared.HardwareErrorCode.BlePermissionError, hdShared.HardwareErrorCode.BleLocationError, hdShared.HardwareErrorCode.BleDeviceNotBonded, hdShared.HardwareErrorCode.BleCharacteristicNotifyError].includes(error.errorCode)) {
19399
19423
  reject(error);
19400
19424
  return;
19401
19425
  }
@@ -19451,6 +19475,12 @@ const cleanup = () => {
19451
19475
  Log.debug('Cleanup...');
19452
19476
  };
19453
19477
 
19478
+ const removeDeviceListener = device => {
19479
+ device.removeListener(DEVICE.PIN, onDevicePinHandler);
19480
+ device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
19481
+ device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
19482
+ };
19483
+
19454
19484
  const closePopup = () => {
19455
19485
  postMessage(createUiMessage(UI_REQUEST$1.CLOSE_UI_WINDOW));
19456
19486
  };
@@ -20809,6 +20839,7 @@ const HardwareErrorCode = {
20809
20839
  DeviceUnexpectedBootloaderMode: 108,
20810
20840
  DeviceInterruptedFromUser: 109,
20811
20841
  DeviceCheckDeviceIdError: 110,
20842
+ DeviceNotSupportPassphrase: 111,
20812
20843
  NotInitialized: 200,
20813
20844
  IFrameNotInitialized: 300,
20814
20845
  IFrameAleradyInitialized: 301,
@@ -20858,6 +20889,7 @@ const HardwareErrorCodeMessage = {
20858
20889
  [HardwareErrorCode.DeviceInterruptedFromUser]: 'Device interrupted',
20859
20890
  [HardwareErrorCode.DeviceUnexpectedBootloaderMode]: 'Device should be in bootloader mode',
20860
20891
  [HardwareErrorCode.DeviceCheckDeviceIdError]: 'Device Id in the features is not same.',
20892
+ [HardwareErrorCode.DeviceNotSupportPassphrase]: 'Device not support passphrase',
20861
20893
  [HardwareErrorCode.NotInitialized]: 'Not initialized',
20862
20894
  [HardwareErrorCode.IFrameNotInitialized]: 'IFrame not initialized',
20863
20895
  [HardwareErrorCode.IFrameAleradyInitialized]: 'IFrame alerady initialized',
@@ -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.22"
46128
46160
  });
46129
46161
  return true;
46130
46162
  } catch (e) {