@onekeyfe/hd-transport-http 1.1.26 → 1.1.27-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 +4 -4
- 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 HttpTransport {
|
|
|
13
13
|
stopped: boolean;
|
|
14
14
|
url: string;
|
|
15
15
|
Log?: any;
|
|
16
|
+
getProtocolType(_path: string): ProtocolType;
|
|
16
17
|
constructor(url?: string);
|
|
17
18
|
_post(options: IncompleteRequestOptions): Promise<any>;
|
|
18
19
|
init(logger: any): Promise<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,EAA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
|
|
128
128
|
const DEFAULT_URL = 'http://localhost:21320';
|
|
129
129
|
|
|
130
|
-
const { check,
|
|
130
|
+
const { check, ProtocolV1, parseConfigure } = transport__default["default"];
|
|
131
131
|
class HttpTransport {
|
|
132
|
+
getProtocolType(_path) {
|
|
133
|
+
return 'V1';
|
|
134
|
+
}
|
|
132
135
|
constructor(url) {
|
|
133
136
|
this.name = 'HttpTransport';
|
|
134
137
|
this.configured = false;
|
|
@@ -219,7 +222,7 @@ class HttpTransport {
|
|
|
219
222
|
else {
|
|
220
223
|
this.Log.debug('call-', ' name: ', name, ' data: ', data);
|
|
221
224
|
}
|
|
222
|
-
const o =
|
|
225
|
+
const o = ProtocolV1.encodeEnvelope(messages, name, data);
|
|
223
226
|
const outData = o.toString('hex');
|
|
224
227
|
const resData = yield this._post({
|
|
225
228
|
url: `/call/${session}`,
|
|
@@ -229,7 +232,7 @@ class HttpTransport {
|
|
|
229
232
|
if (typeof resData !== 'string') {
|
|
230
233
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NetworkError, 'Returning data is not string.');
|
|
231
234
|
}
|
|
232
|
-
const jsonData =
|
|
235
|
+
const jsonData = ProtocolV1.decodeMessage(messages, resData);
|
|
233
236
|
return check.call(jsonData);
|
|
234
237
|
});
|
|
235
238
|
}
|
|
@@ -239,7 +242,7 @@ class HttpTransport {
|
|
|
239
242
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.TransportNotConfigured);
|
|
240
243
|
}
|
|
241
244
|
const messages = this._messages;
|
|
242
|
-
const outData =
|
|
245
|
+
const outData = ProtocolV1.encodeEnvelope(messages, name, data).toString('hex');
|
|
243
246
|
yield this._post({
|
|
244
247
|
url: `/post/${session}`,
|
|
245
248
|
body: outData,
|
|
@@ -258,7 +261,7 @@ class HttpTransport {
|
|
|
258
261
|
if (typeof resData !== 'string') {
|
|
259
262
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.NetworkError, 'Returning data is not string.');
|
|
260
263
|
}
|
|
261
|
-
const jsonData =
|
|
264
|
+
const jsonData = ProtocolV1.decodeMessage(messages, resData);
|
|
262
265
|
return check.call(jsonData);
|
|
263
266
|
});
|
|
264
267
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-http",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.27-alpha.30",
|
|
4
4
|
"description": "hardware http 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.
|
|
28
|
-
"@onekeyfe/hd-transport": "1.1.
|
|
27
|
+
"@onekeyfe/hd-shared": "1.1.27-alpha.30",
|
|
28
|
+
"@onekeyfe/hd-transport": "1.1.27-alpha.30",
|
|
29
29
|
"axios": "1.15.2",
|
|
30
30
|
"secure-json-parse": "^4.0.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "f1e3a93e766463007436eaa9aff4a271ffd8830c"
|
|
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 HttpTransport {
|
|
|
27
31
|
|
|
28
32
|
Log?: any;
|
|
29
33
|
|
|
34
|
+
// HttpTransport (Bridge) speaks Protocol V1 only.
|
|
35
|
+
getProtocolType(_path: string): ProtocolType {
|
|
36
|
+
return 'V1';
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
constructor(url?: string) {
|
|
31
40
|
this.url = url == null ? DEFAULT_URL : url;
|
|
32
41
|
}
|
|
@@ -117,7 +126,7 @@ export default class HttpTransport {
|
|
|
117
126
|
this.Log.debug('call-', ' name: ', name, ' data: ', data);
|
|
118
127
|
}
|
|
119
128
|
|
|
120
|
-
const o =
|
|
129
|
+
const o = ProtocolV1.encodeEnvelope(messages, name, data);
|
|
121
130
|
const outData = o.toString('hex');
|
|
122
131
|
const resData = await this._post({
|
|
123
132
|
url: `/call/${session}`,
|
|
@@ -127,7 +136,7 @@ export default class HttpTransport {
|
|
|
127
136
|
if (typeof resData !== 'string') {
|
|
128
137
|
throw ERRORS.TypedError(HardwareErrorCode.NetworkError, 'Returning data is not string.');
|
|
129
138
|
}
|
|
130
|
-
const jsonData =
|
|
139
|
+
const jsonData = ProtocolV1.decodeMessage(messages, resData);
|
|
131
140
|
return check.call(jsonData);
|
|
132
141
|
}
|
|
133
142
|
|
|
@@ -136,7 +145,7 @@ export default class HttpTransport {
|
|
|
136
145
|
throw ERRORS.TypedError(HardwareErrorCode.TransportNotConfigured);
|
|
137
146
|
}
|
|
138
147
|
const messages = this._messages;
|
|
139
|
-
const outData =
|
|
148
|
+
const outData = ProtocolV1.encodeEnvelope(messages, name, data).toString('hex');
|
|
140
149
|
await this._post({
|
|
141
150
|
url: `/post/${session}`,
|
|
142
151
|
body: outData,
|
|
@@ -154,7 +163,7 @@ export default class HttpTransport {
|
|
|
154
163
|
if (typeof resData !== 'string') {
|
|
155
164
|
throw ERRORS.TypedError(HardwareErrorCode.NetworkError, 'Returning data is not string.');
|
|
156
165
|
}
|
|
157
|
-
const jsonData =
|
|
166
|
+
const jsonData = ProtocolV1.decodeMessage(messages, resData);
|
|
158
167
|
return check.call(jsonData);
|
|
159
168
|
}
|
|
160
169
|
|