@onekeyfe/hd-web-sdk 0.1.23 → 0.1.26

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.
@@ -4133,6 +4133,10 @@ const inject = ({
4133
4133
  connectId,
4134
4134
  method: 'deviceUpdateReboot'
4135
4135
  }),
4136
+ deviceSupportFeatures: connectId => call({
4137
+ connectId,
4138
+ method: 'deviceSupportFeatures'
4139
+ }),
4136
4140
  deviceVerify: (connectId, params) => call(Object.assign(Object.assign({}, params), {
4137
4141
  connectId,
4138
4142
  method: 'deviceVerify'
@@ -13670,9 +13674,25 @@ const getDeviceBLEFirmwareVersion = features => {
13670
13674
  return null;
13671
13675
  }
13672
13676
 
13677
+ if (!semver__default["default"].valid(features.ble_ver)) {
13678
+ return null;
13679
+ }
13680
+
13673
13681
  return features.ble_ver.split('.');
13674
13682
  };
13675
13683
 
13684
+ const supportInputPinOnSoftware = features => {
13685
+ if (!features) return false;
13686
+ const deviceType = getDeviceType(features);
13687
+
13688
+ if (deviceType === 'touch') {
13689
+ return false;
13690
+ }
13691
+
13692
+ const currentVersion = getDeviceFirmwareVersion(features).join('.');
13693
+ return semver__default["default"].gte(currentVersion, '2.3.0');
13694
+ };
13695
+
13676
13696
  const HD_HARDENED = 0x80000000;
13677
13697
 
13678
13698
  const toHardened = n => (n | HD_HARDENED) >>> 0;
@@ -14351,6 +14371,7 @@ const DEVICE = {
14351
14371
  PASSPHRASE: 'passphrase',
14352
14372
  PASSPHRASE_ON_DEVICE: 'passphrase_on_device',
14353
14373
  WORD: 'word',
14374
+ SUPPORT_FEATURES: 'support_features',
14354
14375
  FEATURES: 'features'
14355
14376
  };
14356
14377
 
@@ -14468,6 +14489,8 @@ class DeviceCommands {
14468
14489
  }
14469
14490
 
14470
14491
  _filterCommonTypes(res) {
14492
+ var _a;
14493
+
14471
14494
  Log$4.debug('_filterCommonTypes: ', res);
14472
14495
 
14473
14496
  if (res.type === 'Failure') {
@@ -14506,6 +14529,10 @@ class DeviceCommands {
14506
14529
  return Promise.resolve(patchFeatures(res));
14507
14530
  }
14508
14531
 
14532
+ if ((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.passphrase_protection) {
14533
+ return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportPassphrase));
14534
+ }
14535
+
14509
14536
  if (res.type === 'ButtonRequest') {
14510
14537
  if (res.message.code === 'ButtonRequest_PassphraseEntry') {
14511
14538
  this.device.emit(DEVICE.PASSPHRASE_ON_DEVICE, this.device);
@@ -14573,7 +14600,7 @@ const UI_REQUEST = {
14573
14600
  FIRMWARE_NOT_INSTALLED: 'ui-device_firmware_not_installed',
14574
14601
  NOT_USE_ONEKEY_DEVICE: 'ui-device_please_use_onekey_device'
14575
14602
  };
14576
- const DEFAULT_DOMAIN = `https://jssdk.onekey.so/`;
14603
+ const DEFAULT_DOMAIN = `https://jssdk.onekey.so/${"0.1.26"}/`;
14577
14604
  const DEFAULT_PRIORITY = 2;
14578
14605
  const initialSettings = {
14579
14606
  configSrc: './data/config.json',
@@ -15212,6 +15239,15 @@ class BaseMethod {
15212
15239
  })));
15213
15240
  }
15214
15241
 
15242
+ checkDeviceSupportFeature() {
15243
+ if (!this.device || !this.device.features) return;
15244
+ const inputPinOnSoftware = supportInputPinOnSoftware(this.device.features);
15245
+ this.postMessage(createDeviceMessage(DEVICE.SUPPORT_FEATURES, {
15246
+ inputPinOnSoftware,
15247
+ device: this.device.toMessageObject()
15248
+ }));
15249
+ }
15250
+
15215
15251
  dispose() {}
15216
15252
 
15217
15253
  }
@@ -16866,6 +16902,20 @@ class DeviceUpdateReboot extends BaseMethod {
16866
16902
 
16867
16903
  }
16868
16904
 
16905
+ class DeviceSupportFeatures extends BaseMethod {
16906
+ init() {}
16907
+
16908
+ run() {
16909
+ if (!this.device.features) return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Device not initialized'));
16910
+ const inputPinOnSoftware = supportInputPinOnSoftware(this.device.features);
16911
+ return Promise.resolve({
16912
+ inputPinOnSoftware,
16913
+ device: this.device.toMessageObject()
16914
+ });
16915
+ }
16916
+
16917
+ }
16918
+
16869
16919
  class DeviceVerify extends BaseMethod {
16870
16920
  init() {
16871
16921
  validateParams(this.payload, [{
@@ -18899,6 +18949,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
18899
18949
  deviceReset: DeviceReset,
18900
18950
  deviceSettings: DeviceSettings,
18901
18951
  deviceUpdateReboot: DeviceUpdateReboot,
18952
+ deviceSupportFeatures: DeviceSupportFeatures,
18902
18953
  deviceVerify: DeviceVerify,
18903
18954
  deviceWipe: DeviceWipe,
18904
18955
  evmGetAddress: EvmGetAddress,
@@ -19226,6 +19277,7 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
19226
19277
  }
19227
19278
 
19228
19279
  method.checkFirmwareRelease();
19280
+ method.checkDeviceSupportFeature();
19229
19281
 
19230
19282
  if (_deviceList) {
19231
19283
  yield TransportManager.reconfigure(device.getFirmwareVersion());
@@ -46072,6 +46124,10 @@ const handleMessage = async message => {
46072
46124
  eventEmitter.emit(message.type, message.payload);
46073
46125
  }
46074
46126
 
46127
+ if (message.type === dist/* DEVICE.SUPPORT_FEATURES */.Td.SUPPORT_FEATURES) {
46128
+ eventEmitter.emit(message.type, message.payload);
46129
+ }
46130
+
46075
46131
  break;
46076
46132
 
46077
46133
  default:
@@ -46162,7 +46218,7 @@ const src_init = async settings => {
46162
46218
 
46163
46219
  try {
46164
46220
  await init({ ..._settings,
46165
- version: "0.1.23"
46221
+ version: "0.1.26"
46166
46222
  });
46167
46223
  return true;
46168
46224
  } catch (e) {
@@ -46172,14 +46228,20 @@ const src_init = async settings => {
46172
46228
  };
46173
46229
 
46174
46230
  const call = async params => {
46175
- src_Log.debug('call : ', params); // lazy load
46231
+ src_Log.debug('call : ', params);
46232
+ /**
46233
+ * Try to recreate iframe if it's initialize failed
46234
+ */
46176
46235
 
46177
46236
  if (!instance && !timeout) {
46178
46237
  _settings = (0,dist/* parseConnectSettings */._4)(_settings);
46238
+ src_Log.debug("Try to recreate iframe if it's initialize failed: ", _settings);
46179
46239
 
46180
46240
  try {
46181
- src_init(_settings);
46241
+ await src_init(_settings);
46242
+ src_Log.debug('Recreate iframe success');
46182
46243
  } catch (error) {
46244
+ src_Log.debug('Recreate iframe failed: ', error);
46183
46245
  return (0,dist/* createErrorMessage */.xG)(error);
46184
46246
  }
46185
46247
  }