@onekeyfe/hd-transport-emulator 1.0.33-alpha.10 → 1.0.37-alpha.3

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/README.md CHANGED
@@ -1,17 +1,13 @@
1
- # @onekeyfe/hd-transport-emulator
1
+ # OneKey Hardware Emulator Transport
2
2
 
3
- Hardware emulator transport for OneKey hardware SDK.
4
-
5
- ## Description
6
-
7
- This package provides a transport layer for communicating with OneKey hardware emulators running on localhost:21321.
3
+ This package provides HTTP-based transport for connecting to OneKey hardware emulator.
8
4
 
9
5
  ## Features
10
6
 
11
- - Connects to OneKey hardware emulator on port 21321
12
- - Compatible with OneKey hardware SDK
13
- - Implements the same interface as other transport layers
14
- - Supports all standard hardware operations
7
+ - HTTP-based communication with emulator server
8
+ - Compatible with OneKey Connect SDK
9
+ - Support for switchTransport functionality
10
+ - Default emulator server URL: `http://localhost:21333`
15
11
 
16
12
  ## Installation
17
13
 
@@ -21,28 +17,77 @@ npm install @onekeyfe/hd-transport-emulator
21
17
 
22
18
  ## Usage
23
19
 
20
+ ### Basic Usage
21
+
24
22
  ```javascript
25
23
  import EmulatorTransport from '@onekeyfe/hd-transport-emulator';
26
24
 
27
- // Create transport instance (default URL: http://localhost:21321)
25
+ // Create transport instance
28
26
  const transport = new EmulatorTransport();
27
+ // or with custom URL
28
+ const transport = new EmulatorTransport('http://localhost:21333');
29
+
30
+ // Initialize transport
31
+ await transport.init(logger);
32
+
33
+ // Configure with protobuf messages
34
+ await transport.configure(signedData);
35
+ ```
29
36
 
30
- // Or specify custom URL
31
- const transport = new EmulatorTransport('http://localhost:21321');
37
+ ### With OneKey Connect SDK
38
+
39
+ ```javascript
40
+ import HardwareSDK from '@onekeyfe/hd-web-sdk';
41
+
42
+ // Initialize with emulator environment
43
+ await HardwareSDK.init({
44
+ env: 'emulator',
45
+ debug: true
46
+ });
47
+
48
+ // Switch to emulator transport
49
+ await HardwareSDK.switchTransport('emulator');
32
50
  ```
33
51
 
34
- ## Configuration
52
+ ### In Connect Examples
35
53
 
36
- The transport uses the following default configuration:
37
- - Port: 21321
38
- - Protocol: HTTP
39
- - Host: localhost
54
+ The emulator transport is integrated into the connect examples:
40
55
 
41
- ## Requirements
56
+ 1. **Expo Example**: Select "Emulator" from the transport picker
57
+ 2. **Electron Example**: Use switchTransport API to switch to emulator
42
58
 
43
- - OneKey hardware emulator running on port 21321
44
- - Node.js environment or modern browser with CORS support
59
+ ## API
45
60
 
46
- ## License
61
+ ### Constructor
47
62
 
48
- ISC
63
+ ```javascript
64
+ new EmulatorTransport(url?: string)
65
+ ```
66
+
67
+ - `url` (optional): Emulator server URL, defaults to `http://localhost:21333`
68
+
69
+ ### Methods
70
+
71
+ All methods implement the standard OneKey Transport interface:
72
+
73
+ - `init(logger)`: Initialize transport
74
+ - `configure(signedData)`: Configure protobuf messages
75
+ - `enumerate()`: List available devices
76
+ - `acquire(input)`: Acquire device session
77
+ - `release(session, onclose)`: Release device session
78
+ - `call(session, name, data)`: Call device method
79
+ - `stop()`: Stop transport
80
+
81
+ ## Emulator Server
82
+
83
+ Make sure your OneKey emulator server is running on the configured URL (default: `http://localhost:21333`) before using this transport.
84
+
85
+ ## Development
86
+
87
+ ```bash
88
+ # Build
89
+ npm run build
90
+
91
+ # Development mode
92
+ npm run dev
93
+ ```
@@ -1,2 +1,2 @@
1
- export declare const DEFAULT_URL = "http://localhost:21321";
1
+ export declare const DEFAULT_URL = "http://localhost:21333";
2
2
  //# sourceMappingURL=constants.d.ts.map
package/dist/index.js CHANGED
@@ -100,16 +100,16 @@ axios__default["default"].interceptors.request.use(config => {
100
100
  if (typeof window !== 'undefined') {
101
101
  return config;
102
102
  }
103
- if ((_a = config.url) === null || _a === void 0 ? void 0 : _a.startsWith('http://localhost:21321')) {
103
+ if ((_a = config.url) === null || _a === void 0 ? void 0 : _a.startsWith('http://localhost:21333')) {
104
104
  if (!((_b = config === null || config === void 0 ? void 0 : config.headers) === null || _b === void 0 ? void 0 : _b.Origin)) {
105
- console.log('set node request origin for emulator');
105
+ console.log('set node request origin');
106
106
  config.headers = Object.assign(Object.assign({}, config.headers), { Origin: 'https://jssdk.onekey.so' });
107
107
  }
108
108
  }
109
109
  return config;
110
110
  });
111
111
 
112
- const DEFAULT_URL = 'http://localhost:21321';
112
+ const DEFAULT_URL = 'http://localhost:21333';
113
113
 
114
114
  const { check, buildOne, receiveOne, parseConfigure } = transport__default["default"];
115
115
  class EmulatorTransport {
@@ -153,7 +153,7 @@ class EmulatorTransport {
153
153
  listen(old) {
154
154
  return __awaiter(this, void 0, void 0, function* () {
155
155
  if (old === null) {
156
- throw hdShared.ERRORS.TypedError('Emulator-Transport does not support listen without previous.');
156
+ throw hdShared.ERRORS.TypedError('Http-Transport does not support listen without previous.');
157
157
  }
158
158
  const devicesS = yield this._post({
159
159
  url: '/listen',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-transport-emulator",
3
- "version": "1.0.33-alpha.10",
3
+ "version": "1.0.37-alpha.3",
4
4
  "description": "hardware emulator transport",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -24,10 +24,10 @@
24
24
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
25
25
  },
26
26
  "dependencies": {
27
- "@onekeyfe/hd-shared": "^1.0.33-alpha.10",
28
- "@onekeyfe/hd-transport": "^1.0.33-alpha.10",
27
+ "@onekeyfe/hd-shared": "^1.0.37-alpha.3",
28
+ "@onekeyfe/hd-transport": "^1.0.37-alpha.3",
29
29
  "axios": "^0.27.2",
30
30
  "secure-json-parse": "^4.0.0"
31
31
  },
32
- "gitHead": "a42d94fe3da1db3d2a2c0821441d884ec928260f"
32
+ "gitHead": "350e6072e38266ae3896a87187294a1302123ff7"
33
33
  }
package/src/constants.ts CHANGED
@@ -1 +1 @@
1
- export const DEFAULT_URL = 'http://localhost:21321';
1
+ export const DEFAULT_URL = 'http://localhost:21333';
package/src/http.ts CHANGED
@@ -71,9 +71,9 @@ axios.interceptors.request.use(config => {
71
71
  return config;
72
72
  }
73
73
  // node environment
74
- if (config.url?.startsWith('http://localhost:21321')) {
74
+ if (config.url?.startsWith('http://localhost:21333')) {
75
75
  if (!config?.headers?.Origin) {
76
- console.log('set node request origin for emulator');
76
+ console.log('set node request origin');
77
77
  // add Origin field for request headers
78
78
  config.headers = {
79
79
  ...config.headers,
package/src/index.ts CHANGED
@@ -68,7 +68,7 @@ export default class EmulatorTransport {
68
68
 
69
69
  async listen(old?: Array<OneKeyDeviceInfoWithSession>) {
70
70
  if (old === null) {
71
- throw ERRORS.TypedError('Emulator-Transport does not support listen without previous.');
71
+ throw ERRORS.TypedError('Http-Transport does not support listen without previous.');
72
72
  }
73
73
  const devicesS = await this._post({
74
74
  url: '/listen',
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "../../tsconfig.lib.json",
3
3
  "compilerOptions": {
4
- "outDir": "./dist"
4
+ "outDir": "dist",
5
5
  },
6
6
  "include": ["src"]
7
- }
7
+ }