@onekeyfe/hd-transport-http 1.0.27-alpha.0 → 1.0.28
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.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/package.json +6 -5
- package/src/http.ts +2 -1
- package/src/index.ts +4 -2
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,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.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;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAMxF,KAAK,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;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,aA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IAMhB,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;IAS3B,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;IAyBjE,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
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
var transport = require('@onekeyfe/hd-transport');
|
|
4
4
|
var hdShared = require('@onekeyfe/hd-shared');
|
|
5
5
|
var axios = require('axios');
|
|
6
|
+
var secureJSON = require('secure-json-parse');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
9
|
|
|
9
10
|
var transport__default = /*#__PURE__*/_interopDefaultLegacy(transport);
|
|
10
11
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
12
|
+
var secureJSON__default = /*#__PURE__*/_interopDefaultLegacy(secureJSON);
|
|
11
13
|
|
|
12
14
|
/******************************************************************************
|
|
13
15
|
Copyright (c) Microsoft Corporation.
|
|
@@ -53,7 +55,7 @@ function wrapBody(body) {
|
|
|
53
55
|
}
|
|
54
56
|
function parseResult(text) {
|
|
55
57
|
try {
|
|
56
|
-
const result =
|
|
58
|
+
const result = secureJSON__default["default"].parse(text);
|
|
57
59
|
if (typeof result !== 'object') {
|
|
58
60
|
throw new Error('Invalid response');
|
|
59
61
|
}
|
|
@@ -167,8 +169,9 @@ class HttpTransport {
|
|
|
167
169
|
});
|
|
168
170
|
}
|
|
169
171
|
_acquireMixed(input) {
|
|
170
|
-
const previousStr = input.previous == null ? 'null' : input.previous;
|
|
171
|
-
const
|
|
172
|
+
const previousStr = input.previous == null ? 'null' : encodeURIComponent(input.previous);
|
|
173
|
+
const path = encodeURIComponent(input.path);
|
|
174
|
+
const url = `/acquire/${path}/${previousStr}`;
|
|
172
175
|
return this._post({ url });
|
|
173
176
|
}
|
|
174
177
|
acquire(input) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-http",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"description": "hardware http transport",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@onekeyfe/hd-shared": "^1.0.
|
|
28
|
-
"@onekeyfe/hd-transport": "^1.0.
|
|
29
|
-
"axios": "^0.27.2"
|
|
27
|
+
"@onekeyfe/hd-shared": "^1.0.28",
|
|
28
|
+
"@onekeyfe/hd-transport": "^1.0.28",
|
|
29
|
+
"axios": "^0.27.2",
|
|
30
|
+
"secure-json-parse": "^4.0.0"
|
|
30
31
|
},
|
|
31
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "e59928917c30423a5d13a502c13b5197d2f55246"
|
|
32
33
|
}
|
package/src/http.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios, { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { HardwareError, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
|
+
import secureJSON from 'secure-json-parse';
|
|
3
4
|
|
|
4
5
|
export type HttpRequestOptions = {
|
|
5
6
|
body?: Array<any> | Record<string, unknown> | string;
|
|
@@ -24,7 +25,7 @@ function wrapBody(body: any) {
|
|
|
24
25
|
|
|
25
26
|
function parseResult(text: string) {
|
|
26
27
|
try {
|
|
27
|
-
const result =
|
|
28
|
+
const result = secureJSON.parse(text);
|
|
28
29
|
if (typeof result !== 'object') {
|
|
29
30
|
throw new Error('Invalid response');
|
|
30
31
|
}
|
package/src/index.ts
CHANGED
|
@@ -81,9 +81,11 @@ export default class HttpTransport {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
_acquireMixed(input: AcquireInput) {
|
|
84
|
-
const previousStr = input.previous == null ? 'null' : input.previous;
|
|
84
|
+
const previousStr = input.previous == null ? 'null' : encodeURIComponent(input.previous);
|
|
85
|
+
// @ts-expect-error
|
|
85
86
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
86
|
-
const
|
|
87
|
+
const path = encodeURIComponent(input.path);
|
|
88
|
+
const url = `/acquire/${path}/${previousStr}`;
|
|
87
89
|
return this._post({ url });
|
|
88
90
|
}
|
|
89
91
|
|