@onekeyfe/hd-transport 0.1.49 → 0.1.51

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.
Files changed (3) hide show
  1. package/README.md +28 -2
  2. package/package.json +2 -2
  3. package/protocol.md +21 -0
package/README.md CHANGED
@@ -1,3 +1,29 @@
1
- # @onekeyfe/transport
1
+ # `@onekeyfe/hd-transport`
2
2
 
3
- 用于与 onekey 固件低级别通信的库
3
+ `@onekeyfe/hd-transport` is a library for low-level communication with OneKey Hardware.
4
+
5
+ ## What is the purpose
6
+
7
+ - translate JSON payloads to binary messages using protobuf definitions comprehensible to OneKey devices
8
+ - chunking and reading chunked messages according to the [OneKey protocol](./protocol.md)
9
+ - exposing single API for various transport methods:
10
+ - Http Transport
11
+ - React Native Transport
12
+ - WebUSB
13
+ - Create and expose typescript definitions based on protobuf definitions.
14
+
15
+ ### The short version
16
+
17
+ In order to be able to use new features of onekey-firmware you need to update protobuf definitions.
18
+
19
+ 1. `git submodule update --init --recursive` to initialize git submodules.
20
+ 1. `yarn update-submodules` to update trezor-common submodule
21
+ 1. `yarn workspace @onekeyfe/transport update:protobuf` to generate new `./messages.json` and `./src/types/messages.ts`
22
+
23
+ git submodule update --init --recursive to initialize trezor-common submodule
24
+ yarn update-submodules to update trezor-common submodule
25
+ yarn workspace @trezor/transport update:protobuf to generate new ./messages.json and ./src/types/messages.ts
26
+
27
+ ## Docs
28
+
29
+ Documentation is available [hardware-js-sdk](https://developer.onekey.so/connect-to-hardware/hardware-sdk/start)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
4
4
  "description": "> TODO: description",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -26,5 +26,5 @@
26
26
  "long": "^4.0.0",
27
27
  "protobufjs": "^6.11.2"
28
28
  },
29
- "gitHead": "692944ef9897d6a9b0069fb60eec18d2dfbd6a2b"
29
+ "gitHead": "0bc84671cf1fabb0f50339407dd43ad82ff096b8"
30
30
  }
package/protocol.md ADDED
@@ -0,0 +1,21 @@
1
+ # OneKey Protocol
2
+
3
+ ## version 1
4
+
5
+ Messages are sent in packets of 64 bytes.
6
+
7
+ First packet has the following structure:
8
+
9
+ | offset | length | type | contents |
10
+ |--------|--------|-------------|---------------------------------------------------------------------------------------|
11
+ | 0 | 3 | char[3] | '?##' magic constant |
12
+ | 3 | 2 | BE uint16_t | numerical [message type](https://github.com/OneKeyHQ/firmware/blob/touch/common/protob/messages.proto) |
13
+ | 5 | 4 | BE uint32_t | message size |
14
+ | 9 | 55 | uint8_t[55] | first 55 bytes of message encoded in Protocol Buffers (padded with zeroes if shorter) |
15
+
16
+ Following packets has the following structure:
17
+
18
+ | offset | length | type | contents |
19
+ |--------|--------|-------------|----------------------------------------------------------------------------------------|
20
+ | 0 | 1 | char[1] | '?' magic constant |
21
+ | 1 | 63 | uint8_t[63] | following bytes of message encoded in Protocol Buffers (padded with zeroes if shorter) |