@onekeyfe/hd-transport-http 1.1.12-alpha.2 → 1.1.13
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.js +4 -5
- package/package.json +5 -5
- package/src/http.ts +4 -8
package/dist/index.js
CHANGED
|
@@ -95,15 +95,14 @@ function request(options) {
|
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
axios__default["default"].interceptors.request.use(config => {
|
|
99
|
-
var _a
|
|
98
|
+
axios__default["default"].interceptors.request.use((config) => {
|
|
99
|
+
var _a;
|
|
100
100
|
if (typeof window !== 'undefined') {
|
|
101
101
|
return config;
|
|
102
102
|
}
|
|
103
103
|
if ((_a = config.url) === null || _a === void 0 ? void 0 : _a.startsWith('http://localhost:21320')) {
|
|
104
|
-
if (!
|
|
105
|
-
|
|
106
|
-
config.headers = Object.assign(Object.assign({}, config.headers), { Origin: 'https://jssdk.onekey.so' });
|
|
104
|
+
if (!config.headers.get('Origin')) {
|
|
105
|
+
config.headers.set('Origin', 'https://jssdk.onekey.so');
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
return config;
|
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.13",
|
|
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.
|
|
29
|
-
"axios": "
|
|
27
|
+
"@onekeyfe/hd-shared": "1.1.13",
|
|
28
|
+
"@onekeyfe/hd-transport": "1.1.13",
|
|
29
|
+
"axios": "1.12.2",
|
|
30
30
|
"secure-json-parse": "^4.0.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "7eaf49349763fb6c63fbd0c2ecb69663c443a72c"
|
|
33
33
|
}
|
package/src/http.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import axios, { AxiosRequestConfig } from 'axios';
|
|
1
|
+
import axios, { AxiosRequestConfig, InternalAxiosRequestConfig } from 'axios';
|
|
2
2
|
import { HardwareError, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
3
|
import secureJSON from 'secure-json-parse';
|
|
4
4
|
|
|
@@ -66,19 +66,15 @@ export async function request(options: HttpRequestOptions) {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
axios.interceptors.request.use(config => {
|
|
69
|
+
axios.interceptors.request.use((config: InternalAxiosRequestConfig) => {
|
|
70
70
|
if (typeof window !== 'undefined') {
|
|
71
71
|
return config;
|
|
72
72
|
}
|
|
73
73
|
// node environment
|
|
74
74
|
if (config.url?.startsWith('http://localhost:21320')) {
|
|
75
|
-
if (!config
|
|
76
|
-
console.log('set node request origin');
|
|
75
|
+
if (!config.headers.get('Origin')) {
|
|
77
76
|
// add Origin field for request headers
|
|
78
|
-
config.headers
|
|
79
|
-
...config.headers,
|
|
80
|
-
Origin: 'https://jssdk.onekey.so',
|
|
81
|
-
};
|
|
77
|
+
config.headers.set('Origin', 'https://jssdk.onekey.so');
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
80
|
return config;
|