@onekeyfe/hd-transport-http 0.1.56 → 0.1.58
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.map +1 -1
- package/dist/index.js +6 -1
- package/package.json +4 -4
- package/src/http.ts +8 -1
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;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,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;AA4BF,wBAAsB,OAAO,CAAC,OAAO,EAAE,kBAAkB,gBA6BxD"}
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,11 @@ function wrapBody(body) {
|
|
|
48
48
|
}
|
|
49
49
|
function parseResult(text) {
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
const result = JSON.parse(text);
|
|
52
|
+
if (typeof result !== 'object') {
|
|
53
|
+
throw new Error('Invalid response');
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
52
56
|
}
|
|
53
57
|
catch (e) {
|
|
54
58
|
return text;
|
|
@@ -66,6 +70,7 @@ function request(options) {
|
|
|
66
70
|
'Content-Type': contentType(options.body == null ? '' : options.body),
|
|
67
71
|
},
|
|
68
72
|
timeout: (_a = options.timeout) !== null && _a !== void 0 ? _a : undefined,
|
|
73
|
+
transformResponse: data => data,
|
|
69
74
|
};
|
|
70
75
|
const res = yield axios__default["default"].request(fetchOptions);
|
|
71
76
|
if (+res.status === 200) {
|
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.58",
|
|
4
4
|
"description": "hardware http transport",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "^0.1.
|
|
29
|
-
"@onekeyfe/hd-transport": "^0.1.
|
|
28
|
+
"@onekeyfe/hd-shared": "^0.1.58",
|
|
29
|
+
"@onekeyfe/hd-transport": "^0.1.58",
|
|
30
30
|
"axios": "^0.27.2"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "bf3eba53bcfdb27466f20a7392970764bcb9237b"
|
|
33
33
|
}
|
package/src/http.ts
CHANGED
|
@@ -24,7 +24,11 @@ function wrapBody(body: any) {
|
|
|
24
24
|
|
|
25
25
|
function parseResult(text: string) {
|
|
26
26
|
try {
|
|
27
|
-
|
|
27
|
+
const result = JSON.parse(text);
|
|
28
|
+
if (typeof result !== 'object') {
|
|
29
|
+
throw new Error('Invalid response');
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
28
32
|
} catch (e) {
|
|
29
33
|
return text;
|
|
30
34
|
}
|
|
@@ -40,6 +44,9 @@ export async function request(options: HttpRequestOptions) {
|
|
|
40
44
|
'Content-Type': contentType(options.body == null ? '' : options.body),
|
|
41
45
|
},
|
|
42
46
|
timeout: options.timeout ?? undefined,
|
|
47
|
+
// Prevent string from converting to number
|
|
48
|
+
// see https://stackoverflow.com/questions/43787712/axios-how-to-deal-with-big-integers
|
|
49
|
+
transformResponse: data => data,
|
|
43
50
|
};
|
|
44
51
|
|
|
45
52
|
const res = await axios.request(fetchOptions);
|