@onekeyfe/hd-transport-emulator 1.1.26-alpha.2 → 1.1.26-alpha.30
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 +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -5
- package/package.json +5 -5
- package/src/index.ts +15 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _onekeyfe_hd_transport from '@onekeyfe/hd-transport';
|
|
2
|
-
import _onekeyfe_hd_transport__default, { OneKeyDeviceInfoWithSession, AcquireInput } from '@onekeyfe/hd-transport';
|
|
2
|
+
import _onekeyfe_hd_transport__default, { ProtocolType, OneKeyDeviceInfoWithSession, AcquireInput } from '@onekeyfe/hd-transport';
|
|
3
3
|
|
|
4
4
|
type IncompleteRequestOptions = {
|
|
5
5
|
body?: Array<any> | Record<string, unknown> | string;
|
|
@@ -13,6 +13,7 @@ declare class EmulatorTransport {
|
|
|
13
13
|
configured: boolean;
|
|
14
14
|
stopped: boolean;
|
|
15
15
|
isOutdated: boolean;
|
|
16
|
+
getProtocolType(_path: string): ProtocolType;
|
|
16
17
|
url: string;
|
|
17
18
|
Log?: any;
|
|
18
19
|
constructor(url?: string);
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAA8B,MAAM,wBAAwB,CAAC;AAMpE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAA8B,MAAM,wBAAwB,CAAC;AAMpE,OAAO,KAAK,EACV,YAAY,EACZ,2BAA2B,EAC3B,YAAY,EACb,MAAM,wBAAwB,CAAC;AAIhC,KAAK,wBAAwB,GAAG;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC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ors.request.use((config) => {
|
|
|
111
111
|
|
|
112
112
|
const DEFAULT_URL = 'http://localhost:21333';
|
|
113
113
|
|
|
114
|
-
const { check,
|
|
114
|
+
const { check, ProtocolV1, parseConfigure } = transport__default["default"];
|
|
115
115
|
class EmulatorTransport {
|
|
116
|
+
getProtocolType(_path) {
|
|
117
|
+
return 'V1';
|
|
118
|
+
}
|
|
116
119
|
constructor(url) {
|
|
117
120
|
this.name = 'EmulatorTransport';
|
|
118
121
|
this.version = '1.0.0';
|
|
@@ -205,7 +208,7 @@ class EmulatorTransport {
|
|
|
205
208
|
else {
|
|
206
209
|
this.Log.debug('call-', ' name: ', name, ' data: ', data);
|
|
207
210
|
}
|
|
208
|
-
const o =
|
|
211
|
+
const o = ProtocolV1.encodeEnvelope(messages, name, data);
|
|
209
212
|
const outData = o.toString('hex');
|
|
210
213
|
const resData = yield this._post({
|
|
211
214
|
url: `/call/${session}`,
|
|
@@ -215,7 +218,7 @@ class EmulatorTransport {
|
|
|
215
218
|
if (typeof resData !== 'string') {
|
|
216
219
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NetworkError, 'Returning data is not string.');
|
|
217
220
|
}
|
|
218
|
-
const jsonData =
|
|
221
|
+
const jsonData = ProtocolV1.decodeMessage(messages, resData);
|
|
219
222
|
return check.call(jsonData);
|
|
220
223
|
});
|
|
221
224
|
}
|
|
@@ -225,7 +228,7 @@ class EmulatorTransport {
|
|
|
225
228
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
|
|
226
229
|
}
|
|
227
230
|
const messages = this._messages;
|
|
228
|
-
const outData =
|
|
231
|
+
const outData = ProtocolV1.encodeEnvelope(messages, name, data).toString('hex');
|
|
229
232
|
yield this._post({
|
|
230
233
|
url: `/post/${session}`,
|
|
231
234
|
body: outData,
|
|
@@ -244,7 +247,7 @@ class EmulatorTransport {
|
|
|
244
247
|
if (typeof resData !== 'string') {
|
|
245
248
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NetworkError, 'Returning data is not string.');
|
|
246
249
|
}
|
|
247
|
-
const jsonData =
|
|
250
|
+
const jsonData = ProtocolV1.decodeMessage(messages, resData);
|
|
248
251
|
return check.call(jsonData);
|
|
249
252
|
});
|
|
250
253
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-emulator",
|
|
3
|
-
"version": "1.1.26-alpha.
|
|
3
|
+
"version": "1.1.26-alpha.30",
|
|
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.1.26-alpha.
|
|
28
|
-
"@onekeyfe/hd-transport": "1.1.26-alpha.
|
|
29
|
-
"axios": "1.15.
|
|
27
|
+
"@onekeyfe/hd-shared": "1.1.26-alpha.30",
|
|
28
|
+
"@onekeyfe/hd-transport": "1.1.26-alpha.30",
|
|
29
|
+
"axios": "1.15.2",
|
|
30
30
|
"secure-json-parse": "^4.0.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "88ec305cb60347e09cf9e0c8e921d414f7fe3656"
|
|
33
33
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,9 +4,13 @@ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
|
4
4
|
import { request as http } from './http';
|
|
5
5
|
import { DEFAULT_URL } from './constants';
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
AcquireInput,
|
|
9
|
+
OneKeyDeviceInfoWithSession,
|
|
10
|
+
ProtocolType,
|
|
11
|
+
} from '@onekeyfe/hd-transport';
|
|
8
12
|
|
|
9
|
-
const { check,
|
|
13
|
+
const { check, ProtocolV1, parseConfigure } = transport;
|
|
10
14
|
|
|
11
15
|
type IncompleteRequestOptions = {
|
|
12
16
|
body?: Array<any> | Record<string, unknown> | string;
|
|
@@ -27,6 +31,11 @@ export default class EmulatorTransport {
|
|
|
27
31
|
|
|
28
32
|
isOutdated = false;
|
|
29
33
|
|
|
34
|
+
// EmulatorTransport speaks Protocol V1 only.
|
|
35
|
+
getProtocolType(_path: string): ProtocolType {
|
|
36
|
+
return 'V1';
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
url: string;
|
|
31
40
|
|
|
32
41
|
Log?: any;
|
|
@@ -121,7 +130,7 @@ export default class EmulatorTransport {
|
|
|
121
130
|
this.Log.debug('call-', ' name: ', name, ' data: ', data);
|
|
122
131
|
}
|
|
123
132
|
|
|
124
|
-
const o =
|
|
133
|
+
const o = ProtocolV1.encodeEnvelope(messages, name, data);
|
|
125
134
|
const outData = o.toString('hex');
|
|
126
135
|
const resData = await this._post({
|
|
127
136
|
url: `/call/${session}`,
|
|
@@ -131,7 +140,7 @@ export default class EmulatorTransport {
|
|
|
131
140
|
if (typeof resData !== 'string') {
|
|
132
141
|
throw ERRORS.TypedError(HardwareErrorCode.NetworkError, 'Returning data is not string.');
|
|
133
142
|
}
|
|
134
|
-
const jsonData =
|
|
143
|
+
const jsonData = ProtocolV1.decodeMessage(messages, resData);
|
|
135
144
|
return check.call(jsonData);
|
|
136
145
|
}
|
|
137
146
|
|
|
@@ -140,7 +149,7 @@ export default class EmulatorTransport {
|
|
|
140
149
|
throw ERRORS.TypedError(HardwareErrorCode.TransportNotConfigured);
|
|
141
150
|
}
|
|
142
151
|
const messages = this._messages;
|
|
143
|
-
const outData =
|
|
152
|
+
const outData = ProtocolV1.encodeEnvelope(messages, name, data).toString('hex');
|
|
144
153
|
await this._post({
|
|
145
154
|
url: `/post/${session}`,
|
|
146
155
|
body: outData,
|
|
@@ -158,7 +167,7 @@ export default class EmulatorTransport {
|
|
|
158
167
|
if (typeof resData !== 'string') {
|
|
159
168
|
throw ERRORS.TypedError(HardwareErrorCode.NetworkError, 'Returning data is not string.');
|
|
160
169
|
}
|
|
161
|
-
const jsonData =
|
|
170
|
+
const jsonData = ProtocolV1.decodeMessage(messages, resData);
|
|
162
171
|
return check.call(jsonData);
|
|
163
172
|
}
|
|
164
173
|
|