@onekeyfe/hd-transport-react-native 1.2.0-alpha.65 → 1.2.0-alpha.67

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-react-native",
3
- "version": "1.2.0-alpha.65",
3
+ "version": "1.2.0-alpha.67",
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.65",
24
- "@onekeyfe/hd-shared": "1.2.0-alpha.65",
25
- "@onekeyfe/hd-transport": "1.2.0-alpha.65",
23
+ "@onekeyfe/hd-core": "1.2.0-alpha.67",
24
+ "@onekeyfe/hd-shared": "1.2.0-alpha.67",
25
+ "@onekeyfe/hd-transport": "1.2.0-alpha.67",
26
26
  "@onekeyfe/react-native-ble-utils": "^0.1.6",
27
27
  "react-native-ble-plx": "3.5.1"
28
28
  },
29
- "gitHead": "2850b5b34935d4e97a1fe8a6459eb5a96a5cf0f6"
29
+ "gitHead": "5fea66e8c65a1fab2ccc099b2811c8749b2487e0"
30
30
  }
@@ -8,8 +8,7 @@ import ReactNativeBleTransport, {
8
8
  BLE_CONNECT_TIMEOUT_MANAGER_RESET_THRESHOLD,
9
9
  BLE_GATT_SETUP_TIMEOUT_MS,
10
10
  } from '../index';
11
-
12
- import messages from '@onekeyfe/hd-transport/messages.json';
11
+ import protocolV1Schema from './protocolV1SchemaFixture';
13
12
 
14
13
  jest.mock(
15
14
  'react-native',
@@ -114,7 +113,7 @@ function createHarness(connectImpl: () => Promise<unknown>) {
114
113
  { debug: jest.fn(), error: jest.fn(), warn: jest.fn() } as any,
115
114
  new EventEmitter()
116
115
  );
117
- transport.configure(messages);
116
+ transport.configure(protocolV1Schema);
118
117
  return { transport, device, bleManager, connect };
119
118
  }
120
119
 
@@ -1,6 +1,5 @@
1
1
  import ReactNativeBleTransport, { PROTOCOL_REPROBE_FALLBACK_ATTEMPTS } from '../index';
2
-
3
- import messages from '@onekeyfe/hd-transport/messages.json';
2
+ import protocolV1Schema from './protocolV1SchemaFixture';
4
3
 
5
4
  jest.mock(
6
5
  'react-native',
@@ -38,7 +37,7 @@ const UUID = 'reprobe-device';
38
37
  /** Drive detectProtocol with stubbed probes so we can observe which are attempted. */
39
38
  function createHarness({ v1, v2 }: { v1: boolean; v2: boolean }) {
40
39
  const transport = new ReactNativeBleTransport({});
41
- transport.configure(messages);
40
+ transport.configure(protocolV1Schema);
42
41
  const probeV1 = jest.fn(() => {
43
42
  if (v1) {
44
43
  (transport as any).deviceProtocol.set(UUID, 'V1');
@@ -0,0 +1,39 @@
1
+ const protocolV1Schema = {
2
+ nested: {
3
+ Initialize: {
4
+ fields: {
5
+ session_id: { type: 'bytes', id: 1 },
6
+ derive_cardano: { type: 'bool', id: 3 },
7
+ },
8
+ },
9
+ GetFeatures: { fields: {} },
10
+ Success: {
11
+ fields: {
12
+ message: { type: 'string', id: 1 },
13
+ },
14
+ },
15
+ Ping: {
16
+ fields: {
17
+ message: { type: 'string', id: 1 },
18
+ button_protection: { type: 'bool', id: 2 },
19
+ },
20
+ },
21
+ FirmwareUpload: {
22
+ fields: {
23
+ payload: { rule: 'required', type: 'bytes', id: 1 },
24
+ hash: { type: 'bytes', id: 2 },
25
+ },
26
+ },
27
+ MessageType: {
28
+ values: {
29
+ MessageType_Initialize: 0,
30
+ MessageType_Ping: 1,
31
+ MessageType_Success: 2,
32
+ MessageType_FirmwareUpload: 7,
33
+ MessageType_GetFeatures: 55,
34
+ },
35
+ },
36
+ },
37
+ };
38
+
39
+ export default protocolV1Schema;
@@ -1,8 +1,7 @@
1
1
  import { HardwareErrorCode } from '@onekeyfe/hd-shared';
2
2
 
3
3
  import ReactNativeBleTransport from '../index';
4
-
5
- import messages from '@onekeyfe/hd-transport/messages.json';
4
+ import protocolV1Schema from './protocolV1SchemaFixture';
6
5
 
7
6
  jest.mock(
8
7
  'react-native',
@@ -44,7 +43,7 @@ const flush = () =>
44
43
 
45
44
  function createHarness() {
46
45
  const t = new ReactNativeBleTransport({});
47
- t.configure(messages);
46
+ t.configure(protocolV1Schema);
48
47
  (t as any).deviceProtocol.set(UUID, 'V1');
49
48
  const writeWithoutResponse = jest.fn(() => Promise.resolve());
50
49
  const fakeBleTransport = {
@@ -4,8 +4,7 @@ import ReactNativeBleTransport, {
4
4
  BLE_WRITE_PACKET_TIMEOUT_MS,
5
5
  BLE_WRITE_TIMEOUT_MANAGER_RESET_THRESHOLD,
6
6
  } from '../index';
7
-
8
- import messages from '@onekeyfe/hd-transport/messages.json';
7
+ import protocolV1Schema from './protocolV1SchemaFixture';
9
8
 
10
9
  jest.mock(
11
10
  'react-native',
@@ -67,7 +66,7 @@ async function drain(totalMs: number, stepMs = 500) {
67
66
 
68
67
  function createHarness(writeImpl: () => Promise<void>) {
69
68
  const t = new ReactNativeBleTransport({});
70
- t.configure(messages);
69
+ t.configure(protocolV1Schema);
71
70
  (t as any).deviceProtocol.set(UUID, 'V1');
72
71
  const writeWithoutResponse = jest.fn(writeImpl);
73
72
  const fakeBleTransport = {