@onekeyfe/hd-transport-web-device 1.2.0-alpha.178 → 1.2.0-alpha.179

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.
@@ -327,7 +327,7 @@ describe('ElectronBleTransport protocol detection', () => {
327
327
  }
328
328
  });
329
329
 
330
- test('reconnects Protocol V1 with a non-destructive GetFeatures probe', async () => {
330
+ test('reconnects a declared Protocol V1 device without probing again', async () => {
331
331
  const device = { id: 'classic-id', name: 'OneKey Classic' };
332
332
  const nobleBle = createNobleBle(device);
333
333
  let notificationHandler: ((deviceId: string, data: string) => void) | undefined;
@@ -360,7 +360,10 @@ describe('ElectronBleTransport protocol detection', () => {
360
360
  uuid: device.id,
361
361
  })
362
362
  );
363
- expect(nobleBle.write).toHaveBeenCalledTimes(2);
363
+ // The first acquire probes because the protocol is unknown; the second
364
+ // declares V1 and must send nothing at all, leaving the first frame on
365
+ // the link to Core — which is what carries the wallet session.
366
+ expect(nobleBle.write).toHaveBeenCalledTimes(1);
364
367
  expect(nobleBle.write.mock.calls.every(([, hex]) => /^3f23230037/.test(hex))).toBe(true);
365
368
  expect(protocolV2Writer).not.toHaveBeenCalled();
366
369
  } finally {
@@ -373,19 +376,13 @@ describe('ElectronBleTransport protocol detection', () => {
373
376
  const nobleBle = createNobleBle(device);
374
377
  let notificationHandler: ((deviceId: string, data: string) => void) | undefined;
375
378
  const v1ResponseHex = '3f23230002000000040a026f6b';
376
- let writeCount = 0;
377
-
378
379
  nobleBle.onNotification.mockImplementation(handler => {
379
380
  notificationHandler = handler;
380
381
  return jest.fn();
381
382
  });
382
- nobleBle.write.mockImplementation(() => {
383
- writeCount += 1;
384
- if (writeCount === 1) {
385
- setTimeout(() => notificationHandler?.(device.id, v1ResponseHex), 0);
386
- }
387
- return Promise.resolve();
388
- });
383
+ // A declared V1 acquire writes nothing, so every write here belongs to the
384
+ // call under test and none of them is answered.
385
+ nobleBle.write.mockImplementation(() => Promise.resolve());
389
386
  const bleTransport = configureTransport(nobleBle);
390
387
 
391
388
  await bleTransport.acquire({ uuid: device.id, expectedProtocol: 'V1' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-web-device",
3
- "version": "1.2.0-alpha.178",
3
+ "version": "1.2.0-alpha.179",
4
4
  "author": "OneKey",
5
5
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
6
6
  "license": "MIT",
@@ -21,13 +21,13 @@
21
21
  "lint:fix": "eslint . --fix"
22
22
  },
23
23
  "dependencies": {
24
- "@onekeyfe/hd-shared": "1.2.0-alpha.178",
25
- "@onekeyfe/hd-transport": "1.2.0-alpha.178"
24
+ "@onekeyfe/hd-shared": "1.2.0-alpha.179",
25
+ "@onekeyfe/hd-transport": "1.2.0-alpha.179"
26
26
  },
27
27
  "devDependencies": {
28
- "@onekeyfe/hd-transport-electron": "1.2.0-alpha.178",
28
+ "@onekeyfe/hd-transport-electron": "1.2.0-alpha.179",
29
29
  "@types/w3c-web-usb": "^1.0.6",
30
30
  "@types/web-bluetooth": "^0.0.17"
31
31
  },
32
- "gitHead": "5df24cf8ab1b0e1909e5d9715b15ab042bba3ac7"
32
+ "gitHead": "dcdc4387e00db0beb5b4adba53a9408537549578"
33
33
  }