@onekeyfe/hd-web-sdk 0.1.49 → 0.1.50

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.
@@ -14779,6 +14779,7 @@ const UI_REQUEST$1 = {
14779
14779
  REQUEST_PIN: 'ui-request_pin',
14780
14780
  INVALID_PIN: 'ui-invalid_pin',
14781
14781
  REQUEST_BUTTON: 'ui-button',
14782
+ REQUEST_PASSPHRASE: 'ui-request_passphrase',
14782
14783
  REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request_passphrase_on_device',
14783
14784
  CLOSE_UI_WINDOW: 'ui-close_window',
14784
14785
  BLUETOOTH_PERMISSION: 'ui-bluetooth_permission',
@@ -14818,7 +14819,8 @@ const createResponseMessage = (id, success, payload) => ({
14818
14819
  });
14819
14820
 
14820
14821
  const UI_RESPONSE = {
14821
- RECEIVE_PIN: 'ui-receive_pin'
14822
+ RECEIVE_PIN: 'ui-receive_pin',
14823
+ RECEIVE_PASSPHRASE: 'ui-receive_passphrase'
14822
14824
  };
14823
14825
 
14824
14826
  const createUiResponse = (type, payload) => ({
@@ -14977,7 +14979,6 @@ class DevicePool extends events.exports {
14977
14979
  }
14978
14980
  }
14979
14981
 
14980
- Log$7.debug('get devices result : ', devices, deviceList);
14981
14982
  console.log('device poll -> connected: ', this.connectedPool);
14982
14983
  console.log('device poll -> disconnected: ', this.disconnectPool);
14983
14984
  yield this._checkDevicePool(initOptions);
@@ -15384,9 +15385,17 @@ class DeviceCommands {
15384
15385
  }
15385
15386
 
15386
15387
  if (res.type === 'PassphraseRequest') {
15387
- return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotSupportPassphrase, 'Device not support passphrase', {
15388
- require: '2.4.0'
15389
- }));
15388
+ return this._promptPassphrase().then(response => {
15389
+ const {
15390
+ passphrase,
15391
+ passphraseOnDevice
15392
+ } = response;
15393
+ return !passphraseOnDevice ? this._commonCall('PassphraseAck', {
15394
+ passphrase
15395
+ }) : this._commonCall('PassphraseAck', {
15396
+ on_device: true
15397
+ });
15398
+ });
15390
15399
  }
15391
15400
 
15392
15401
  if (res.type === 'Deprecated_PassphraseStateRequest') ;
@@ -15414,6 +15423,26 @@ class DeviceCommands {
15414
15423
  });
15415
15424
  }
15416
15425
 
15426
+ _promptPassphrase() {
15427
+ return new Promise((resolve, reject) => {
15428
+ if (this.device.listenerCount(DEVICE.PASSPHRASE) > 0) {
15429
+ this._cancelableRequest = reject;
15430
+ this.device.emit(DEVICE.PASSPHRASE, this.device, (response, error) => {
15431
+ this._cancelableRequest = undefined;
15432
+
15433
+ if (error) {
15434
+ reject(error);
15435
+ } else {
15436
+ resolve(response);
15437
+ }
15438
+ });
15439
+ } else {
15440
+ Log$5.error('[DeviceCommands] [call] Passphrase callback not configured, cancelling request');
15441
+ reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, '_promptPassphrase: Passphrase callback not configured'));
15442
+ }
15443
+ });
15444
+ }
15445
+
15417
15446
  }
15418
15447
 
15419
15448
  const UI_REQUEST = {
@@ -20935,7 +20964,8 @@ const callAPI = message => __awaiter(void 0, void 0, void 0, function* () {
20935
20964
  (_a = method.setDevice) === null || _a === void 0 ? void 0 : _a.call(method, device);
20936
20965
  device.on(DEVICE.PIN, onDevicePinHandler);
20937
20966
  device.on(DEVICE.BUTTON, onDeviceButtonHandler);
20938
- device.on(DEVICE.PASSPHRASE_ON_DEVICE, onDevicePassphraseHandler);
20967
+ device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
20968
+ device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
20939
20969
  device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
20940
20970
 
20941
20971
  try {
@@ -21288,7 +21318,8 @@ const cleanup = () => {
21288
21318
  const removeDeviceListener = device => {
21289
21319
  device.removeListener(DEVICE.PIN, onDevicePinHandler);
21290
21320
  device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
21291
- device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onDevicePassphraseHandler);
21321
+ device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
21322
+ device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
21292
21323
  device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
21293
21324
  DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
21294
21325
  };
@@ -21345,7 +21376,26 @@ const onDeviceFeaturesHandler = (...[_, features]) => {
21345
21376
  postMessage(createDeviceMessage(DEVICE.FEATURES, Object.assign({}, features)));
21346
21377
  };
21347
21378
 
21348
- const onDevicePassphraseHandler = (...[device]) => {
21379
+ const onDevicePassphraseHandler = (...[device, callback]) => __awaiter(void 0, void 0, void 0, function* () {
21380
+ Log.debug('onDevicePassphraseHandler');
21381
+ const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PASSPHRASE, device);
21382
+ postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE, {
21383
+ device: device.toMessageObject()
21384
+ }));
21385
+ const uiResp = yield uiPromise.promise;
21386
+ const {
21387
+ value,
21388
+ passphraseOnDevice,
21389
+ save
21390
+ } = uiResp.payload;
21391
+ callback({
21392
+ passphrase: value.normalize('NFKD'),
21393
+ passphraseOnDevice,
21394
+ cache: save
21395
+ });
21396
+ });
21397
+
21398
+ const onEnterPassphraseOnDeviceHandler = (...[device]) => {
21349
21399
  postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE_ON_DEVICE, {
21350
21400
  device: device.toMessageObject(),
21351
21401
  passphraseState: device.passphraseState
@@ -21377,6 +21427,7 @@ class Core extends events.exports {
21377
21427
  return __awaiter(this, void 0, void 0, function* () {
21378
21428
  switch (message.type) {
21379
21429
  case UI_RESPONSE.RECEIVE_PIN:
21430
+ case UI_RESPONSE.RECEIVE_PASSPHRASE:
21380
21431
  {
21381
21432
  const uiPromise = findUiPromise(message.type);
21382
21433
 
@@ -45606,7 +45657,7 @@ try {
45606
45657
  /***/ ((module) => {
45607
45658
 
45608
45659
  "use strict";
45609
- module.exports = JSON.parse('{"name":"@onekeyfe/hd-core","version":"0.1.49","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.49","@onekeyfe/hd-transport":"^0.1.49","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"}}');
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"}}');
45610
45661
 
45611
45662
  /***/ })
45612
45663
 
@@ -48138,7 +48189,7 @@ const src_init = async settings => {
48138
48189
 
48139
48190
  try {
48140
48191
  await init({ ..._settings,
48141
- version: "0.1.49"
48192
+ version: "0.1.50"
48142
48193
  });
48143
48194
  return true;
48144
48195
  } catch (e) {