@onekeyfe/hd-transport-react-native 1.2.0-alpha.125 → 1.2.0-alpha.126
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.
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAIL,UAAU,IAAI,aAAa,EAG5B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,SAAS,EAAE,EAChB,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAKjB,KAAK,oBAAoB,EAI1B,MAAM,wBAAwB,CAAC;AA0BhC,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAI1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,KAAK,YAAY,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAgBjE,KAAK,4BAA4B,GAAG,WAAW,CAAC;AAChD,KAAK,0BAA0B,GAAG;IAChC,mBAAmB,EAAE,cAAc,CAAC;IACpC,oBAAoB,EAAE,cAAc,CAAC;CACtC,CAAC;AAkCF,eAAO,MAAM,+BAA+B,UACnC,OAAO,KACb,4BAA4B,GAAG,IAsBjC,CAAC;AAcF,eAAO,MAAM,2BAA2B,QAAS,CAAC;AAOlD,eAAO,MAAM,yCAAyC,IAAI,CAAC;AAI3D,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAiBF,wBAAgB,4BAA4B,CAAC,MAAM,GAAE,mBAAwB,QAY5E;AAED,wBAAgB,wBAAwB,SAGvC;AAED,w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ePlx.ScanMode.LowLatency,
|
|
660
660
|
}, (error, device) => {
|
|
661
|
-
var _a;
|
|
661
|
+
var _a, _b;
|
|
662
662
|
if (error) {
|
|
663
663
|
Log === null || Log === void 0 ? void 0 : Log.debug('ble scan error: ', error);
|
|
664
664
|
if ([reactNativeBlePlx.BleErrorCode.BluetoothPoweredOff, reactNativeBlePlx.BleErrorCode.BluetoothInUnknownState].includes(error.errorCode)) {
|
|
@@ -685,7 +685,7 @@ class ReactNativeBleTransport {
|
|
|
685
685
|
id: device === null || device === void 0 ? void 0 : device.id,
|
|
686
686
|
name: device === null || device === void 0 ? void 0 : device.name,
|
|
687
687
|
localName: device === null || device === void 0 ? void 0 : device.localName,
|
|
688
|
-
serviceUuids: device === null || device === void 0 ? void 0 : device.serviceUUIDs,
|
|
688
|
+
serviceUuids: (_b = device === null || device === void 0 ? void 0 : device.serviceUUIDs) !== null && _b !== void 0 ? _b : getBluetoothServiceUuids(),
|
|
689
689
|
});
|
|
690
690
|
if (isOneKey) {
|
|
691
691
|
addDevice(device);
|
|
@@ -1593,7 +1593,7 @@ class ReactNativeBleTransport {
|
|
|
1593
1593
|
detectProtocol(uuid, expectedProtocol, protocolHint, rebuildTransport) {
|
|
1594
1594
|
var _a;
|
|
1595
1595
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1596
|
-
if (reactNative.Platform.OS === 'ios' && expectedProtocol) {
|
|
1596
|
+
if (reactNative.Platform.OS === 'ios' && expectedProtocol === 'V1') {
|
|
1597
1597
|
this.deviceProtocol.set(uuid, expectedProtocol);
|
|
1598
1598
|
Log === null || Log === void 0 ? void 0 : Log.debug('[ReactNativeBleTransport] protocol selected', {
|
|
1599
1599
|
deviceId: uuid,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-react-native",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.126",
|
|
4
4
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"lint:fix": "eslint . --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@onekeyfe/hd-core": "1.2.0-alpha.
|
|
24
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
25
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
23
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.126",
|
|
24
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.126",
|
|
25
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.126",
|
|
26
26
|
"@onekeyfe/react-native-ble-utils": "^0.1.6",
|
|
27
27
|
"react-native-ble-plx": "3.5.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "c82189b36d650aec460a6f29bd467bf16a74e510"
|
|
30
30
|
}
|
|
@@ -84,6 +84,30 @@ describe('ReactNativeBleTransport iOS discovery', () => {
|
|
|
84
84
|
expect(devices.map(device => device.id)).toEqual(['wallet-peripheral']);
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
test('keeps a service-filtered Pro2 scan result when ble-plx omits service UUIDs', async () => {
|
|
88
|
+
jest.mocked(getConnectedDeviceIds).mockResolvedValueOnce([]);
|
|
89
|
+
const blePlxManager = {
|
|
90
|
+
startDeviceScan: jest.fn((_serviceUUIDs, _options, listener) => {
|
|
91
|
+
queueMicrotask(() => {
|
|
92
|
+
listener(null, {
|
|
93
|
+
id: 'wallet-peripheral',
|
|
94
|
+
name: 'Pro2 6E9E - Find My',
|
|
95
|
+
localName: null,
|
|
96
|
+
serviceUUIDs: null,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}),
|
|
100
|
+
stopDeviceScan: jest.fn(),
|
|
101
|
+
};
|
|
102
|
+
const transport = new ReactNativeBleTransport({ scanTimeout: 1 });
|
|
103
|
+
transport.blePlxManager = blePlxManager as never;
|
|
104
|
+
transport.init({ debug: jest.fn(), error: jest.fn() }, new EventEmitter());
|
|
105
|
+
|
|
106
|
+
const devices = await transport.enumerate();
|
|
107
|
+
|
|
108
|
+
expect(devices.map(device => device.id)).toEqual(['wallet-peripheral']);
|
|
109
|
+
});
|
|
110
|
+
|
|
87
111
|
test('ignores an unnamed scanned advertisement while keeping the named wallet peripheral', async () => {
|
|
88
112
|
jest.mocked(getConnectedDeviceIds).mockResolvedValueOnce([]);
|
|
89
113
|
const blePlxManager = {
|
|
@@ -61,6 +61,30 @@ const detect = (transport: ReactNativeBleTransport) =>
|
|
|
61
61
|
Promise.resolve()
|
|
62
62
|
) as Promise<string>;
|
|
63
63
|
|
|
64
|
+
describe('iOS expected-protocol detection', () => {
|
|
65
|
+
test('still probes an expected Protocol V2 so USB-priority can surface', async () => {
|
|
66
|
+
const { transport, probeV1, probeV2 } = createHarness({ v1: false, v2: true });
|
|
67
|
+
|
|
68
|
+
await expect(
|
|
69
|
+
(transport as any).detectProtocol(UUID, 'V2', undefined, () => Promise.resolve())
|
|
70
|
+
).resolves.toBe('V2');
|
|
71
|
+
|
|
72
|
+
expect(probeV2).toHaveBeenCalledTimes(1);
|
|
73
|
+
expect(probeV1).not.toHaveBeenCalled();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('keeps the existing iOS shortcut for an expected Protocol V1', async () => {
|
|
77
|
+
const { transport, probeV1, probeV2 } = createHarness({ v1: false, v2: false });
|
|
78
|
+
|
|
79
|
+
await expect(
|
|
80
|
+
(transport as any).detectProtocol(UUID, 'V1', undefined, () => Promise.resolve())
|
|
81
|
+
).resolves.toBe('V1');
|
|
82
|
+
|
|
83
|
+
expect(probeV1).not.toHaveBeenCalled();
|
|
84
|
+
expect(probeV2).not.toHaveBeenCalled();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
64
88
|
describe('protocol re-probe after a known device goes away', () => {
|
|
65
89
|
test('an unknown device still probes both protocols', async () => {
|
|
66
90
|
const { transport, probeV1, probeV2 } = createHarness({ v1: false, v2: false });
|
|
@@ -625,7 +625,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
|
|
|
625
625
|
await transport.acquire({ uuid, expectedProtocol: 'V2' });
|
|
626
626
|
await transport.call(uuid, 'Ping', { message: 'first-core-command' });
|
|
627
627
|
|
|
628
|
-
expect(sentSeqs).toEqual([1]);
|
|
628
|
+
expect(sentSeqs).toEqual([1, 2]);
|
|
629
629
|
await transport.release(uuid, true);
|
|
630
630
|
});
|
|
631
631
|
|
|
@@ -660,7 +660,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
|
|
|
660
660
|
await transport.acquire({ uuid, expectedProtocol: 'V2' });
|
|
661
661
|
await transport.call(uuid, 'Ping', { message: 'second-generation' });
|
|
662
662
|
|
|
663
|
-
expect(sentSeqs).toEqual([1, 2]);
|
|
663
|
+
expect(sentSeqs).toEqual([1, 2, 3, 4]);
|
|
664
664
|
await transport.release(uuid, true);
|
|
665
665
|
});
|
|
666
666
|
|
|
@@ -670,12 +670,12 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
|
|
|
670
670
|
await transport.acquire({ uuid, expectedProtocol: 'V2' });
|
|
671
671
|
const releaseNative = jest.spyOn(transport as any, 'releaseNative');
|
|
672
672
|
expect(writeCharacteristic.writeWithoutResponse).not.toHaveBeenCalled();
|
|
673
|
-
expect(writeCharacteristic.writeWithResponse).
|
|
673
|
+
expect(writeCharacteristic.writeWithResponse).toHaveBeenCalledTimes(1);
|
|
674
674
|
|
|
675
675
|
await transport.call(uuid, 'DeviceInfoGet', {});
|
|
676
676
|
await transport.call(uuid, 'ProtocolInfoRequest', {});
|
|
677
677
|
|
|
678
|
-
expect(writeCharacteristic.writeWithResponse).toHaveBeenCalledTimes(
|
|
678
|
+
expect(writeCharacteristic.writeWithResponse).toHaveBeenCalledTimes(3);
|
|
679
679
|
expect(writeCharacteristic.writeWithoutResponse).not.toHaveBeenCalled();
|
|
680
680
|
expect(releaseNative).not.toHaveBeenCalled();
|
|
681
681
|
|
|
@@ -690,7 +690,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
|
|
|
690
690
|
await transport.call(uuid, 'FileWrite', {});
|
|
691
691
|
await transport.call(uuid, 'FileWrite', {});
|
|
692
692
|
expect(writeCharacteristic.writeWithoutResponse).toHaveBeenCalledTimes(2);
|
|
693
|
-
expect(writeCharacteristic.writeWithResponse).
|
|
693
|
+
expect(writeCharacteristic.writeWithResponse).toHaveBeenCalledTimes(1);
|
|
694
694
|
expect(
|
|
695
695
|
logger.debug.mock.calls.filter(
|
|
696
696
|
([message]) =>
|
|
@@ -723,7 +723,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
|
|
|
723
723
|
await transport.acquire({ uuid, expectedProtocol: 'V2' });
|
|
724
724
|
|
|
725
725
|
await transport.call(uuid, 'FileWrite', {}, { writeWithResponse: true });
|
|
726
|
-
expect(writeCharacteristic.writeWithResponse).toHaveBeenCalledTimes(
|
|
726
|
+
expect(writeCharacteristic.writeWithResponse).toHaveBeenCalledTimes(2);
|
|
727
727
|
expect(writeCharacteristic.writeWithoutResponse).not.toHaveBeenCalled();
|
|
728
728
|
await transport.release(uuid, true);
|
|
729
729
|
});
|
|
@@ -737,7 +737,7 @@ describe('ReactNativeBleTransport Protocol V2 link lifecycle', () => {
|
|
|
737
737
|
await transport.call(uuid, 'ProtocolInfoRequest', {});
|
|
738
738
|
|
|
739
739
|
expect(writeCharacteristic.writeWithResponse).not.toHaveBeenCalled();
|
|
740
|
-
expect(writeCharacteristic.writeWithoutResponse).toHaveBeenCalledTimes(
|
|
740
|
+
expect(writeCharacteristic.writeWithoutResponse).toHaveBeenCalledTimes(2);
|
|
741
741
|
await transport.release(uuid, true);
|
|
742
742
|
});
|
|
743
743
|
|
package/src/index.ts
CHANGED
|
@@ -719,7 +719,9 @@ export default class ReactNativeBleTransport {
|
|
|
719
719
|
id: device?.id,
|
|
720
720
|
name: device?.name,
|
|
721
721
|
localName: device?.localName,
|
|
722
|
-
|
|
722
|
+
// The native scan is already restricted to the OneKey communication service,
|
|
723
|
+
// but ble-plx permits the returned advertisement field to be null.
|
|
724
|
+
serviceUuids: device?.serviceUUIDs ?? getBluetoothServiceUuids(),
|
|
723
725
|
});
|
|
724
726
|
if (isOneKey) {
|
|
725
727
|
addDevice(device as unknown as Device);
|
|
@@ -1882,7 +1884,10 @@ export default class ReactNativeBleTransport {
|
|
|
1882
1884
|
protocolHint?: ProtocolType,
|
|
1883
1885
|
rebuildTransport?: () => Promise<void>
|
|
1884
1886
|
): Promise<ProtocolType> {
|
|
1885
|
-
|
|
1887
|
+
// iOS still skips an extra V1 Initialize during acquire. Expected V2 must
|
|
1888
|
+
// Ping so USB-priority `link disabled` can surface instead of a later
|
|
1889
|
+
// unmapped RuntimeError.
|
|
1890
|
+
if (Platform.OS === 'ios' && expectedProtocol === 'V1') {
|
|
1886
1891
|
this.deviceProtocol.set(uuid, expectedProtocol);
|
|
1887
1892
|
Log?.debug('[ReactNativeBleTransport] protocol selected', {
|
|
1888
1893
|
deviceId: uuid,
|