@onekeyfe/hd-core 0.2.32 → 0.2.33

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FirmwareUpdateV2.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,UAAU,CAAC;AAItD,aAAK,MAAM,GAAG;IACZ,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,KAAK,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,UAAU,CAAC,MAAM,CAAC;IAC9D,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,IAAI;IAsCJ,cAAc,YAAa,MAAM,UAS/B;IAEF,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS;IAkDrD,qBAAqB,CAAC,QAAQ,EAAE,QAAQ;IAUxC,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM;IAc9D,gCAAgC,CAAC,QAAQ,CAAC,EAAE,QAAQ;IAwB9C,GAAG;CAiGV"}
1
+ {"version":3,"file":"FirmwareUpdateV2.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV2.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAIT,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,OAAO,KAAK,EAAe,QAAQ,EAAE,MAAM,UAAU,C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3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";AACA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAqBlC,OAAO,EACL,WAAW,EAYZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAC;AAE7D,OAAO,eAAe,MAAM,2BAA2B,CAAC;AA4BxD,eAAO,MAAM,OAAO,YAAmB,WAAW,iBA+PjD,CAAC;AAqMF,eAAO,MAAM,MAAM,0CAkBlB,CAAC;AA8IF,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,YAAY;IACtC,aAAa,CAAC,OAAO,EAAE,WAAW;IA8CxC,OAAO;CAGR;AAED,eAAO,MAAM,QAAQ,YAGpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAIzB,CAAC;AAMF,eAAO,MAAM,IAAI,aAAoB,eAAe,aAAa,GAAG,8BAmBnE,CAAC"}
@@ -10,7 +10,7 @@ export default class DeviceConnector {
10
10
  enumerate(): Promise<DeviceDescriptorDiff | undefined>;
11
11
  listen(): Promise<void>;
12
12
  stop(): void;
13
- acquire(path: string, session?: string | null): Promise<string | undefined>;
13
+ acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean): Promise<string | undefined>;
14
14
  release(session: string, onclose: boolean): Promise<void>;
15
15
  _reportDevicesChange(): void;
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DeviceConnector.d.ts","sourceRoot":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAIzF,OAAO,EAAc,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMhE,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAS,EAAE,SAAS,CAAC;IAErB,eAAe,SAAK;IAEpB,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAQ;IAE1C,QAAQ,EAAE,gBAAgB,EAAE,CAAM;IAElC,SAAS,UAAS;;IAQZ,SAAS;IAWT,MAAM;IAiCZ,IAAI;IAIE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAiB7C,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAS/C,oBAAoB;CAGrB"}
1
+ {"version":3,"file":"DeviceConnector.d.ts","sourceRoot":"","sources":["../../src/device/DeviceConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAIzF,OAAO,EAAc,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAMhE,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,SAAS,EAAE,SAAS,CAAC;IAErB,eAAe,SAAK;IAEpB,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAQ;IAE1C,QAAQ,EAAE,gBAAgB,EAAE,CAAM;IAElC,SAAS,UAAS;;IAQZ,SAAS;IAWT,MAAM;IAiCZ,IAAI;IAIE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,oBAAoB,CAAC,EAAE,OAAO;IAiB7E,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAS/C,oBAAoB;CAGrB"}
package/dist/index.d.ts CHANGED
@@ -10,7 +10,6 @@ interface CommonParams {
10
10
  pollIntervalTime?: number;
11
11
  timeout?: number;
12
12
  passphraseState?: string;
13
- useEmptyPassphrase?: boolean;
14
13
  initSession?: boolean;
15
14
  }
16
15
  declare type Params<T> = CommonParams & T & {
@@ -1918,7 +1917,7 @@ declare class DeviceConnector {
1918
1917
  enumerate(): Promise<DeviceDescriptorDiff | undefined>;
1919
1918
  listen(): Promise<void>;
1920
1919
  stop(): void;
1921
- acquire(path: string, session?: string | null): Promise<string | undefined>;
1920
+ acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean): Promise<string | undefined>;
1922
1921
  release(session: string, onclose: boolean): Promise<void>;
1923
1922
  _reportDevicesChange(): void;
1924
1923
  }
package/dist/index.js CHANGED
@@ -13599,7 +13599,7 @@ class FirmwareUpdateV2 extends BaseMethod {
13599
13599
  var _a, _b, _c, _d, _e, _f, _g, _h;
13600
13600
  if (isBleReconnect) {
13601
13601
  try {
13602
- yield ((_a = this.device.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.device.originalDescriptor.id));
13602
+ yield ((_a = this.device.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.device.originalDescriptor.id, null, true));
13603
13603
  yield this.device.initialize();
13604
13604
  if ((_b = this.device.features) === null || _b === void 0 ? void 0 : _b.bootloader_mode) {
13605
13605
  clearInterval(intervalTimer);
@@ -18305,14 +18305,14 @@ class DeviceConnector {
18305
18305
  stop() {
18306
18306
  this.listening = false;
18307
18307
  }
18308
- acquire(path, session) {
18308
+ acquire(path, session, forceCleanRunPromise) {
18309
18309
  return __awaiter(this, void 0, void 0, function* () {
18310
18310
  Log$1.debug('acquire', path, session);
18311
18311
  const env = DataManager.getSettings('env');
18312
18312
  try {
18313
18313
  let res;
18314
18314
  if (env === 'react-native') {
18315
- res = yield this.transport.acquire({ uuid: path });
18315
+ res = yield this.transport.acquire({ uuid: path, forceCleanRunPromise });
18316
18316
  }
18317
18317
  else {
18318
18318
  res = yield this.transport.acquire({ path, previous: session !== null && session !== void 0 ? session : null });
@@ -18413,7 +18413,7 @@ const callAPI = (message) => __awaiter(void 0, void 0, void 0, function* () {
18413
18413
  (_a = method.setDevice) === null || _a === void 0 ? void 0 : _a.call(method, device);
18414
18414
  device.on(DEVICE.PIN, onDevicePinHandler);
18415
18415
  device.on(DEVICE.BUTTON, onDeviceButtonHandler);
18416
- device.on(DEVICE.PASSPHRASE, message.payload.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler);
18416
+ device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
18417
18417
  device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
18418
18418
  device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
18419
18419
  try {
@@ -18717,9 +18717,7 @@ const cancel = (connectId) => {
18717
18717
  const checkPassphraseSafety = (method, features) => {
18718
18718
  if (!method.useDevicePassphraseState)
18719
18719
  return;
18720
- if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true &&
18721
- (method.payload.passphraseState == null || method.payload.passphraseState === '') &&
18722
- !method.payload.useEmptyPassphrase) {
18720
+ if ((features === null || features === void 0 ? void 0 : features.passphrase_protection) === true && !method.payload.passphraseState) {
18723
18721
  DevicePool.clearDeviceCache(method.payload.connectId);
18724
18722
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceOpenedPassphrase);
18725
18723
  }
@@ -18733,7 +18731,11 @@ const cleanup = () => {
18733
18731
  Log.debug('Cleanup...');
18734
18732
  };
18735
18733
  const removeDeviceListener = (device) => {
18736
- device.removeAllListeners();
18734
+ device.removeListener(DEVICE.PIN, onDevicePinHandler);
18735
+ device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
18736
+ device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
18737
+ device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
18738
+ device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
18737
18739
  DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
18738
18740
  };
18739
18741
  const closePopup = () => {
@@ -18789,10 +18791,6 @@ const onDevicePassphraseHandler = (...[device, callback]) => __awaiter(void 0, v
18789
18791
  cache: save,
18790
18792
  });
18791
18793
  });
18792
- const onEmptyPassphraseHandler = (...[_, callback]) => {
18793
- Log.debug('onEmptyPassphraseHandler');
18794
- callback({ passphrase: '' });
18795
- };
18796
18794
  const onEnterPassphraseOnDeviceHandler = (...[device]) => {
18797
18795
  postMessage(createUiMessage(UI_REQUEST$1.REQUEST_PASSPHRASE_ON_DEVICE, {
18798
18796
  device: device.toMessageObject(),
@@ -4,7 +4,6 @@ export interface CommonParams {
4
4
  pollIntervalTime?: number;
5
5
  timeout?: number;
6
6
  passphraseState?: string;
7
- useEmptyPassphrase?: boolean;
8
7
  initSession?: boolean;
9
8
  }
10
9
  export declare type Params<T> = CommonParams & T & {
@@ -1 +1 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/types/params.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,eAAe,CAAC,EAAE,MAAM,CAAC;IAIzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAI7B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,oBAAY,MAAM,CAAC,CAAC,IAAI,YAAY,GAAG,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,oBAAY,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC"}
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/types/params.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IAItB,UAAU,CAAC,EAAE,MAAM,CAAC;IAIpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAI1B,OAAO,CAAC,EAAE,MAAM,CAAC;IAIjB,eAAe,CAAC,EAAE,MAAM,CAAC;IAIzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,oBAAY,MAAM,CAAC,CAAC,IAAI,YAAY,GAAG,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAElE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD;AAED,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,oBAAY,QAAQ,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "0.2.32",
3
+ "version": "0.2.33",
4
4
  "description": "> TODO: description",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -24,8 +24,8 @@
24
24
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
25
25
  },
26
26
  "dependencies": {
27
- "@onekeyfe/hd-shared": "^0.2.32",
28
- "@onekeyfe/hd-transport": "^0.2.32",
27
+ "@onekeyfe/hd-shared": "^0.2.33",
28
+ "@onekeyfe/hd-transport": "^0.2.33",
29
29
  "axios": "^0.27.2",
30
30
  "bignumber.js": "^9.0.2",
31
31
  "jszip": "^3.10.1",
@@ -42,5 +42,5 @@
42
42
  "@types/semver": "^7.3.9",
43
43
  "ripple-keypairs": "^1.1.4"
44
44
  },
45
- "gitHead": "361f104ba3c7c74eaf3916e71e9790aaf373a11b"
45
+ "gitHead": "c9180a19c4b3faf1e47ed119ecaa91f35cae27c5"
46
46
  }
@@ -91,7 +91,11 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
91
91
  async () => {
92
92
  if (isBleReconnect) {
93
93
  try {
94
- await this.device.deviceConnector?.acquire(this.device.originalDescriptor.id);
94
+ await this.device.deviceConnector?.acquire(
95
+ this.device.originalDescriptor.id,
96
+ null,
97
+ true
98
+ );
95
99
  await this.device.initialize();
96
100
  if (this.device.features?.bootloader_mode) {
97
101
  clearInterval(intervalTimer);
package/src/core/index.ts CHANGED
@@ -133,10 +133,7 @@ export const callAPI = async (message: CoreMessage) => {
133
133
 
134
134
  device.on(DEVICE.PIN, onDevicePinHandler);
135
135
  device.on(DEVICE.BUTTON, onDeviceButtonHandler);
136
- device.on(
137
- DEVICE.PASSPHRASE,
138
- message.payload.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler
139
- );
136
+ device.on(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
140
137
  device.on(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
141
138
  device.on(DEVICE.FEATURES, onDeviceFeaturesHandler);
142
139
 
@@ -543,11 +540,7 @@ export const cancel = (connectId?: string) => {
543
540
  const checkPassphraseSafety = (method: BaseMethod, features?: Features) => {
544
541
  if (!method.useDevicePassphraseState) return;
545
542
 
546
- if (
547
- features?.passphrase_protection === true &&
548
- (method.payload.passphraseState == null || method.payload.passphraseState === '') &&
549
- !method.payload.useEmptyPassphrase
550
- ) {
543
+ if (features?.passphrase_protection === true && !method.payload.passphraseState) {
551
544
  DevicePool.clearDeviceCache(method.payload.connectId);
552
545
  throw ERRORS.TypedError(HardwareErrorCode.DeviceOpenedPassphrase);
553
546
  }
@@ -564,7 +557,11 @@ const cleanup = () => {
564
557
  };
565
558
 
566
559
  const removeDeviceListener = (device: Device) => {
567
- device.removeAllListeners();
560
+ device.removeListener(DEVICE.PIN, onDevicePinHandler);
561
+ device.removeListener(DEVICE.BUTTON, onDeviceButtonHandler);
562
+ device.removeListener(DEVICE.PASSPHRASE, onDevicePassphraseHandler);
563
+ device.removeListener(DEVICE.PASSPHRASE_ON_DEVICE, onEnterPassphraseOnDeviceHandler);
564
+ device.removeListener(DEVICE.FEATURES, onDeviceFeaturesHandler);
568
565
  DevicePool.emitter.removeListener(DEVICE.CONNECT, onDeviceConnectHandler);
569
566
  // DevicePool.emitter.removeListener(DEVICE.DISCONNECT, onDeviceDisconnectHandler);
570
567
  };
@@ -644,12 +641,6 @@ const onDevicePassphraseHandler = async (...[device, callback]: DeviceEvents['pa
644
641
  });
645
642
  };
646
643
 
647
- const onEmptyPassphraseHandler = (...[_, callback]: DeviceEvents['passphrase']) => {
648
- Log.debug('onEmptyPassphraseHandler');
649
- // send as PassphrasePromptResponse
650
- callback({ passphrase: '' });
651
- };
652
-
653
644
  const onEnterPassphraseOnDeviceHandler = (
654
645
  ...[device]: [...DeviceEvents['passphrase_on_device']]
655
646
  ) => {
@@ -73,13 +73,13 @@ export default class DeviceConnector {
73
73
  this.listening = false;
74
74
  }
75
75
 
76
- async acquire(path: string, session?: string | null) {
76
+ async acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean) {
77
77
  Log.debug('acquire', path, session);
78
78
  const env = DataManager.getSettings('env');
79
79
  try {
80
80
  let res;
81
81
  if (env === 'react-native') {
82
- res = await this.transport.acquire({ uuid: path });
82
+ res = await this.transport.acquire({ uuid: path, forceCleanRunPromise });
83
83
  } else {
84
84
  res = await this.transport.acquire({ path, previous: session ?? null });
85
85
  }
@@ -16,10 +16,6 @@ export interface CommonParams {
16
16
  * passphrase state
17
17
  */
18
18
  passphraseState?: string;
19
- /**
20
- * Use empty passphrase
21
- */
22
- useEmptyPassphrase?: boolean;
23
19
  /**
24
20
  * Every init session
25
21
  */