@onekeyfe/hd-transport-http 0.1.13 → 0.1.14
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/http.d.ts +1 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/package.json +4 -4
- package/src/http.ts +2 -0
- package/src/index.ts +1 -0
package/dist/http.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare type HttpRequestOptions = {
|
|
|
2
2
|
body?: Array<any> | Record<string, unknown> | string;
|
|
3
3
|
url: string;
|
|
4
4
|
method: 'POST' | 'GET';
|
|
5
|
+
timeout?: number;
|
|
5
6
|
};
|
|
6
7
|
export declare function request(options: HttpRequestOptions): Promise<any>;
|
|
7
8
|
//# sourceMappingURL=http.d.ts.map
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAGA,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAGA,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAwBF,wBAAsB,OAAO,CAAC,OAAO,EAAE,kBAAkB,gBAuBxD"}
|
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,SAAS,MAAM,wBAAwB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAMxF,aAAK,wBAAwB,GAAG;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACrD,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,GAAG,EAAE,MAAM,CAAC;gBAEA,GAAG,CAAC,EAAE,MAAM;IAKxB,KAAK,CAAC,OAAO,EAAE,wBAAwB;IAWjC,IAAI;IAKJ,WAAW;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAMxF,aAAK,wBAAwB,GAAG;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;IACrD,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAIF,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,SAAS,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,cAAc,CAAC,GAAG,SAAS,CAAC;IAEnE,UAAU,UAAS;IAEnB,OAAO,UAAS;IAEhB,GAAG,EAAE,MAAM,CAAC;gBAEA,GAAG,CAAC,EAAE,MAAM;IAKxB,KAAK,CAAC,OAAO,EAAE,wBAAwB;IAWjC,IAAI;IAKJ,WAAW;IAUjB,SAAS,CAAC,UAAU,EAAE,GAAG;IAMnB,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,2BAA2B,CAAC;IAY/C,SAAS;IAMf,aAAa,CAAC,KAAK,EAAE,YAAY;IAO3B,OAAO,CAAC,KAAK,EAAE,YAAY;IAK3B,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAUzC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAmBjE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAYjE,IAAI,CAAC,OAAO,EAAE,MAAM;IAe1B,aAAa;IAKb,IAAI;IAIJ,MAAM;CAGP"}
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ function parseResult(text) {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
function request(options) {
|
|
58
|
+
var _a;
|
|
58
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
60
|
const fetchOptions = {
|
|
60
61
|
url: options.url,
|
|
@@ -64,6 +65,7 @@ function request(options) {
|
|
|
64
65
|
headers: {
|
|
65
66
|
'Content-Type': contentType(options.body == null ? '' : options.body),
|
|
66
67
|
},
|
|
68
|
+
timeout: (_a = options.timeout) !== null && _a !== void 0 ? _a : undefined,
|
|
67
69
|
};
|
|
68
70
|
const res = yield axios__default["default"].request(fetchOptions);
|
|
69
71
|
if (+res.status === 200) {
|
|
@@ -107,6 +109,7 @@ class HttpTransport {
|
|
|
107
109
|
const infoS = yield request({
|
|
108
110
|
url: this.url,
|
|
109
111
|
method: 'POST',
|
|
112
|
+
timeout: 3000,
|
|
110
113
|
});
|
|
111
114
|
const info = check.info(infoS);
|
|
112
115
|
return info.version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-http",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "hardware http transport",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@onekeyfe/hd-shared": "^0.1.
|
|
28
|
-
"@onekeyfe/hd-transport": "^0.1.
|
|
27
|
+
"@onekeyfe/hd-shared": "^0.1.14",
|
|
28
|
+
"@onekeyfe/hd-transport": "^0.1.14",
|
|
29
29
|
"axios": "^0.27.2"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "216fee1795067013da0d68f4fc25f583509bb509"
|
|
32
32
|
}
|
package/src/http.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type HttpRequestOptions = {
|
|
|
5
5
|
body?: Array<any> | Record<string, unknown> | string;
|
|
6
6
|
url: string;
|
|
7
7
|
method: 'POST' | 'GET';
|
|
8
|
+
timeout?: number;
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
function contentType(body: any) {
|
|
@@ -38,6 +39,7 @@ export async function request(options: HttpRequestOptions) {
|
|
|
38
39
|
headers: {
|
|
39
40
|
'Content-Type': contentType(options.body == null ? '' : options.body),
|
|
40
41
|
},
|
|
42
|
+
timeout: options.timeout ?? undefined,
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
const res = await axios.request(fetchOptions);
|