@tuya-sat/micro-dev-proxy 3.2.24 → 3.3.0

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.
@@ -17,6 +17,7 @@ export interface AppProxyConfig {
17
17
  export declare function GSdf(): any;
18
18
  export default class AppProxy {
19
19
  target: string;
20
+ targetOrigin: string;
20
21
  username: string;
21
22
  password: string;
22
23
  csrf: boolean;
package/dist/appProxy.js CHANGED
@@ -68,6 +68,7 @@ class AppProxy {
68
68
  this.csrfCookie = new token_1.default();
69
69
  this.csrfValue = new token_1.default();
70
70
  this.target = target;
71
+ this.targetOrigin = new url_1.URL(this.target).origin;
71
72
  if (!isMainApp) {
72
73
  this.username = username;
73
74
  if (password) {
@@ -201,6 +202,7 @@ class AppProxy {
201
202
  Object.entries(combineHeaders).forEach(([headerKey, value]) => proxyReq.setHeader(headerKey, value));
202
203
  const prevCookie = proxyReq.getHeader('cookie') || '';
203
204
  proxyReq.setHeader('cookie', this.getCookie(prevCookie));
205
+ proxyReq.setHeader('origin', this.targetOrigin);
204
206
  }
205
207
  combinedHeader(prevHeadar) {
206
208
  let proccessedHeader = Object.assign({}, prevHeadar);
package/dist/index.js CHANGED
@@ -35,7 +35,7 @@ function awaiting() {
35
35
  exports.awaiting = awaiting;
36
36
  function createProxy(_a) {
37
37
  var { additionHeaders = {} } = _a, restPrevConfig = __rest(_a, ["additionHeaders"]);
38
- const config = Object.assign({ additionHeaders: Object.assign({ terminalId: os_1.default.hostname() + Date.now() }, additionHeaders), isMainApp: restPrevConfig.isMainApp, loginApi: '/api/login', needProxyApi: ['/api', '/open-api', '/custom-api'], logSign: false, csrf: true }, restPrevConfig);
38
+ const config = Object.assign({ additionHeaders: Object.assign({ terminalId: os_1.default.hostname() + Date.now() }, additionHeaders), isMainApp: restPrevConfig.isMainApp, loginApi: '/api/login', needProxyApi: ['/api', '/open-api', '/custom-api', '/ws'], logSign: false, csrf: true }, restPrevConfig);
39
39
  const { needProxyApi } = config, appProxyConfig = __rest(config, ["needProxyApi"]);
40
40
  const appProxy = new appProxy_1.default(appProxyConfig);
41
41
  return function middleware(app) {
@@ -47,9 +47,11 @@ function createProxy(_a) {
47
47
  });
48
48
  app.use(needProxyApi, (0, http_proxy_middleware_1.createProxyMiddleware)({
49
49
  target: appProxyConfig.target,
50
+ ws: true,
50
51
  secure: false,
51
52
  changeOrigin: true,
52
53
  selfHandleResponse: true,
54
+ onProxyReqWs: appProxy.processReq.bind(appProxy),
53
55
  onProxyReq: appProxy.processReq.bind(appProxy),
54
56
  onProxyRes: (0, http_proxy_middleware_1.responseInterceptor)(appProxy.processRes.bind(appProxy)),
55
57
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-proxy",
3
- "version": "3.2.24",
3
+ "version": "3.3.0",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {