@onekeyfe/hd-web-sdk 0.1.50 → 0.1.51

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.
@@ -15310,11 +15310,11 @@ class DeviceCommands {
15310
15310
  _commonCall(type, msg) {
15311
15311
  return __awaiter(this, void 0, void 0, function* () {
15312
15312
  const resp = yield this.call(type, msg);
15313
- return this._filterCommonTypes(resp);
15313
+ return this._filterCommonTypes(resp, type);
15314
15314
  });
15315
15315
  }
15316
15316
 
15317
- _filterCommonTypes(res) {
15317
+ _filterCommonTypes(res, callType) {
15318
15318
  Log$5.debug('_filterCommonTypes: ', res);
15319
15319
 
15320
15320
  if (res.type === 'Failure') {
@@ -15344,6 +15344,10 @@ class DeviceCommands {
15344
15344
  error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BlindSignDisabled);
15345
15345
  }
15346
15346
 
15347
+ if (code === 'Failure_UnexpectedMessage' && callType === 'PassphraseAck') {
15348
+ error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.UnexpectPassphrase);
15349
+ }
15350
+
15347
15351
  if (error) {
15348
15352
  return Promise.reject(error);
15349
15353
  }
@@ -15579,6 +15583,7 @@ class Device extends events.exports {
15579
15583
  this.needReloadDevice = false;
15580
15584
  this.keepSession = false;
15581
15585
  this.passphraseState = undefined;
15586
+ this.skipPassphraseCheck = false;
15582
15587
  this.originalDescriptor = descriptor;
15583
15588
  }
15584
15589
 
@@ -15718,10 +15723,11 @@ class Device extends events.exports {
15718
15723
  getInternalState(_deviceId) {
15719
15724
  var _a, _b;
15720
15725
 
15721
- Log$4.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `passphraseState: ${this.passphraseState}`);
15726
+ Log$4.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `passphraseState: ${this.passphraseState}`, `skipPassphraseCheck: ${this.skipPassphraseCheck}`);
15722
15727
  Log$4.debug('getInternalState session cache: ', deviceSessionCache);
15723
15728
  const deviceId = _deviceId || ((_b = this.features) === null || _b === void 0 ? void 0 : _b.device_id);
15724
15729
  if (!deviceId) return undefined;
15730
+ if (this.skipPassphraseCheck) return deviceSessionCache[deviceId];
15725
15731
  if (!this.passphraseState) return undefined;
15726
15732
  const usePassKey = `${deviceId}@${this.passphraseState}`;
15727
15733
 
@@ -15741,7 +15747,11 @@ class Device extends events.exports {
15741
15747
 
15742
15748
  Log$4.debug('setInternalState session param: ', `state: ${state}`, `initSession: ${initSession}`, `device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `passphraseState: ${this.passphraseState}`);
15743
15749
  if (!this.features) return;
15744
- if (!this.passphraseState && !initSession) return;
15750
+
15751
+ if (!this.skipPassphraseCheck) {
15752
+ if (!this.passphraseState && !initSession) return;
15753
+ }
15754
+
15745
15755
  let key = `${this.features.device_id}`;
15746
15756
 
15747
15757
  if (this.passphraseState) {
@@ -15774,6 +15784,7 @@ class Device extends events.exports {
15774
15784
  return __awaiter(this, void 0, void 0, function* () {
15775
15785
  Log$4.debug('initialize param:', options);
15776
15786
  this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
15787
+ this.skipPassphraseCheck = options === null || options === void 0 ? void 0 : options.skipPassphraseCheck;
15777
15788
 
15778
15789
  if (options === null || options === void 0 ? void 0 : options.initSession) {
15779
15790
  this.clearInternalState(options === null || options === void 0 ? void 0 : options.deviceId);
@@ -20876,6 +20887,7 @@ const Log = getLogger(exports.d0.Core);
20876
20887
  const parseInitOptions = method => ({
20877
20888
  initSession: method === null || method === void 0 ? void 0 : method.payload.initSession,
20878
20889
  passphraseState: method === null || method === void 0 ? void 0 : method.payload.passphraseState,
20890
+ skipPassphraseCheck: method === null || method === void 0 ? void 0 : method.payload.skipPassphraseCheck,
20879
20891
  deviceId: method === null || method === void 0 ? void 0 : method.payload.deviceId
20880
20892
  });
20881
20893
 
@@ -21030,12 +21042,14 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
21030
21042
  }));
21031
21043
  }
21032
21044
 
21033
- const passphraseState = yield device.checkPassphraseState();
21034
- checkPassphraseSafety(method, device.features);
21045
+ if (!method.payload.skipPassphraseCheck) {
21046
+ const passphraseState = yield device.checkPassphraseState();
21047
+ checkPassphraseSafety(method, device.features);
21035
21048
 
21036
- if (passphraseState) {
21037
- DevicePool.clearDeviceCache(method.payload.connectId);
21038
- return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError));
21049
+ if (passphraseState) {
21050
+ DevicePool.clearDeviceCache(method.payload.connectId);
21051
+ return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceCheckPassphraseStateError));
21052
+ }
21039
21053
  }
21040
21054
  }
21041
21055
 
@@ -21298,6 +21312,7 @@ const cancel = connectId => {
21298
21312
 
21299
21313
  const checkPassphraseSafety = (method, features) => {
21300
21314
  if (!method.useDevicePassphraseState) return;
21315
+ if (method.payload.skipPassphraseCheck) return;
21301
21316
 
21302
21317
  if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true && !method.payload.passphraseState) {
21303
21318
  DevicePool.clearDeviceCache(method.payload.connectId);
@@ -21380,7 +21395,8 @@ const onDevicePassphraseHandler = (...[device, callback]) => __awaiter(void 0, v
21380
21395
  Log.debug('onDevicePassphraseHandler');
21381
21396
  const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
21382
21397
  postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE, {
21383
- device: device.toMessageObject()
21398
+ device: device.toMessageObject(),
21399
+ passphraseState: device.passphraseState
21384
21400
  }));
21385
21401
  const uiResp = yield uiPromise.promise;
21386
21402
  const {
@@ -22871,7 +22887,8 @@ const HardwareErrorCode = {
22871
22887
  BridgeNotInstalled: 808,
22872
22888
  PollingTimeout: 809,
22873
22889
  PollingStop: 810,
22874
- BlindSignDisabled: 811
22890
+ BlindSignDisabled: 811,
22891
+ UnexpectPassphrase: 812
22875
22892
  };
22876
22893
  const HardwareErrorCodeMessage = {
22877
22894
  [HardwareErrorCode.UnknownError]: 'Unknown error occurred. Check message property.',
@@ -22930,7 +22947,8 @@ const HardwareErrorCodeMessage = {
22930
22947
  [HardwareErrorCode.BridgeNotInstalled]: 'Bridge not installed',
22931
22948
  [HardwareErrorCode.PollingTimeout]: 'Polling timeout',
22932
22949
  [HardwareErrorCode.PollingStop]: 'Polling stop',
22933
- [HardwareErrorCode.BlindSignDisabled]: 'Please confirm the BlindSign enabled'
22950
+ [HardwareErrorCode.BlindSignDisabled]: 'Please confirm the BlindSign enabled',
22951
+ [HardwareErrorCode.UnexpectPassphrase]: 'Unexpect passphrase'
22934
22952
  };
22935
22953
 
22936
22954
  const TypedError = (hardwareError, message, params) => {
@@ -45657,7 +45675,7 @@ try {
45657
45675
  /***/ ((module) => {
45658
45676
 
45659
45677
  "use strict";
45660
- module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.50","description":"> TODO: description","author":"OneKey","homepage":"https://github.com/OneKeyHQ/hardware-js-sdk#readme","license":"ISC","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/OneKeyHQ/hardware-js-sdk.git"},"publishConfig":{"access":"public"},"scripts":{"dev":"rimraf dist && rollup -c ../../build/rollup.config.js -w","build":"rimraf dist && rollup -c ../../build/rollup.config.js","lint":"eslint .","lint:fix":"eslint . --fix"},"bugs":{"url":"https://github.com/OneKeyHQ/hardware-js-sdk/issues"},"dependencies":{"@onekeyfe/hd-shared":"^0.1.50","@onekeyfe/hd-transport":"^0.1.50","axios":"^0.27.2","bignumber.js":"^9.0.2","js-sha256":"^0.9.0","parse-uri":"^1.0.7","semver":"^7.3.7"},"devDependencies":{"@types/parse-uri":"^1.0.0","@types/semver":"^7.3.9"}}');
45678
+ module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.51","description":"> TODO: description","author":"OneKey","homepage":"https://github.com/OneKeyHQ/hardware-js-sdk#readme","license":"ISC","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/OneKeyHQ/hardware-js-sdk.git"},"publishConfig":{"access":"public"},"scripts":{"dev":"rimraf dist && rollup -c ../../build/rollup.config.js -w","build":"rimraf dist && rollup -c ../../build/rollup.config.js","lint":"eslint .","lint:fix":"eslint . --fix"},"bugs":{"url":"https://github.com/OneKeyHQ/hardware-js-sdk/issues"},"dependencies":{"@onekeyfe/hd-shared":"^0.1.51","@onekeyfe/hd-transport":"^0.1.51","axios":"^0.27.2","bignumber.js":"^9.0.2","js-sha256":"^0.9.0","parse-uri":"^1.0.7","semver":"^7.3.7"},"devDependencies":{"@types/parse-uri":"^1.0.0","@types/semver":"^7.3.9"}}');
45661
45679
 
45662
45680
  /***/ })
45663
45681
 
@@ -48189,7 +48207,7 @@ const src_init = async settings => {
48189
48207
 
48190
48208
  try {
48191
48209
  await init({ ..._settings,
48192
- version: "0.1.50"
48210
+ version: "0.1.51"
48193
48211
  });
48194
48212
  return true;
48195
48213
  } catch (e) {