@onekeyfe/hd-core 1.2.0-alpha.30 → 1.2.0-alpha.31

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.
@@ -0,0 +1,58 @@
1
+ import FirmwareUpdateV3 from '../../src/api/FirmwareUpdateV3';
2
+ import type { Device } from '../../src/device/Device';
3
+ import { DevicePool } from '../../src/device/DevicePool';
4
+
5
+ jest.mock('../../src/data/config', () => ({
6
+ getSDKVersion: jest.fn(() => '1.0.0'),
7
+ DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0/',
8
+ }));
9
+
10
+ describe('FirmwareUpdateV3 reconnect', () => {
11
+ afterEach(() => {
12
+ jest.restoreAllMocks();
13
+ });
14
+
15
+ it('keeps transient USB acquire failures inside the reconnect loop', async () => {
16
+ const acquire = jest.fn().mockResolvedValue(undefined);
17
+ const commands = {
18
+ disposed: true,
19
+ mainId: '',
20
+ };
21
+ const cachedDevice = {} as Device;
22
+ const updateFromCache = jest.fn();
23
+ jest.spyOn(DevicePool, 'getDevices').mockResolvedValue({
24
+ devices: {},
25
+ deviceList: [cachedDevice],
26
+ });
27
+
28
+ const method = new FirmwareUpdateV3({
29
+ id: 1,
30
+ payload: {
31
+ method: 'firmwareUpdateV3',
32
+ connectId: 'usb-path',
33
+ },
34
+ });
35
+ method.isBleReconnect = jest.fn(() => false);
36
+ method.device = {
37
+ deviceConnector: {
38
+ enumerate: jest.fn().mockResolvedValue({
39
+ descriptors: [{ path: 'usb-path' }],
40
+ }),
41
+ },
42
+ updateFromCache,
43
+ acquire,
44
+ commands,
45
+ getCommands: () => commands,
46
+ mainId: 'usb-session',
47
+ } as unknown as Device;
48
+
49
+ await method.waitForDeviceReconnect(1000);
50
+
51
+ expect(updateFromCache).toHaveBeenCalledWith(cachedDevice);
52
+ expect(acquire).toHaveBeenCalledWith(undefined, {
53
+ throwOnRunPromiseError: true,
54
+ });
55
+ expect(commands.disposed).toBe(false);
56
+ expect(commands.mainId).toBe('usb-session');
57
+ });
58
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"FirmwareUpdateV3.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV3.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAY/E,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,qBAAqB,CAAC;AAMnE,eAAO,MAAM,gCAAgC,UAAU,CAAC;AAaxD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,wBAAwB,CAAC,sBAAsB,CAAC;IAC5F,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,eAAe,CAA4B;IAEnD,IAAI;IAmFE,GAAG;;;;;YAQK,aAAa;IA6D3B,OAAO,CAAC,wBAAwB;YAiBlB,kBAAkB;YAelB,oBAAoB;IAKlC,OAAO,CAAC,wBAAwB;YAgBlB,oBAAoB;YA2DpB,uBAAuB;YAuBvB,4BAA4B;YA+E5B,aAAa;IAwN3B,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,yBAAyB;IAQjC,OAAO,CAAC,qBAAqB;IAmB7B,OAAO,CAAC,sCAAsC;IAexC,sBAAsB,CAAC,OAAO,EAAE,MAAM;CAuE7C"}
1
+ {"version":3,"file":"FirmwareUpdateV3.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV3.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAY/E,OAAO,KAAK,EAEV,sBAAsB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAiB,MAAM,qBAAqB,CAAC;AAMnE,eAAO,MAAM,gCAAgC,UAAU,CAAC;AAaxD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,wBAAwB,CAAC,sBAAsB,CAAC;IAC5F,YAAY,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAQ;IAE1C,OAAO,CAAC,gBAAgB,CAAS;IAEjC,OAAO,CAAC,eAAe,CAA4B;IAEnD,IAAI;IAmFE,GAAG;;;;;YAQK,aAAa;IA6D3B,OAAO,CAAC,wBAAwB;YAiBlB,kBAAkB;YAelB,oBAAoB;IAKlC,OAAO,CAAC,wBAAwB;YAgBlB,oBAAoB;YA2DpB,uBAAuB;YAuBvB,4BAA4B;YA+E5B,aAAa;IAwN3B,OAAO,CAAC,yBAAyB;IAajC,OAAO,CAAC,yBAAyB;IAQjC,OAAO,CAAC,qBAAqB;IAmB7B,OAAO,CAAC,sCAAsC;IAexC,sBAAsB,CAAC,OAAO,EAAE,MAAM;CA2E7C"}
package/dist/index.js CHANGED
@@ -49474,7 +49474,9 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
49474
49474
  const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, this.connectId);
49475
49475
  if (deviceList.length === 1) {
49476
49476
  this.device.updateFromCache(deviceList[0]);
49477
- yield this.device.acquire();
49477
+ yield this.device.acquire(undefined, {
49478
+ throwOnRunPromiseError: true,
49479
+ });
49478
49480
  this.device.commands.disposed = false;
49479
49481
  this.device.getCommands().mainId = (_d = this.device.mainId) !== null && _d !== void 0 ? _d : '';
49480
49482
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.2.0-alpha.30",
3
+ "version": "1.2.0-alpha.31",
4
4
  "description": "Core processes and APIs for communicating with OneKey hardware devices.",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "1.2.0-alpha.30",
29
- "@onekeyfe/hd-transport": "1.2.0-alpha.30",
28
+ "@onekeyfe/hd-shared": "1.2.0-alpha.31",
29
+ "@onekeyfe/hd-transport": "1.2.0-alpha.31",
30
30
  "axios": "1.15.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -44,5 +44,5 @@
44
44
  "@types/w3c-web-usb": "^1.0.10",
45
45
  "@types/web-bluetooth": "^0.0.21"
46
46
  },
47
- "gitHead": "07405d2e3dcdd0ba351ae98b7cf4f61690ef2913"
47
+ "gitHead": "01354bd66a7ef042a47f45c9ba80c49ba5b241de"
48
48
  }
@@ -746,7 +746,11 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
746
746
 
747
747
  if (deviceList.length === 1) {
748
748
  this.device.updateFromCache(deviceList[0]);
749
- await this.device.acquire();
749
+ // Reconnect failures are expected while installation still owns USB.
750
+ // Keep them in this polling loop instead of rejecting the active firmware run.
751
+ await this.device.acquire(undefined, {
752
+ throwOnRunPromiseError: true,
753
+ });
750
754
  this.device.commands.disposed = false;
751
755
  this.device.getCommands().mainId = this.device.mainId ?? '';
752
756
  return;