@tuya-sat/micro-dev-proxy 3.2.3 → 3.2.5

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/appProxy.js CHANGED
@@ -45,7 +45,6 @@ const util_1 = require("./util");
45
45
  const url_1 = require("url");
46
46
  const fs = __importStar(require("fs"));
47
47
  const path = __importStar(require("path"));
48
- const undici_1 = require("undici");
49
48
  const spinnies_1 = __importDefault(require("spinnies"));
50
49
  const mfPath = path.join(process.cwd(), 'manifest.json');
51
50
  const mf = fs.existsSync(mfPath) && JSON.parse(fs.readFileSync(mfPath, 'utf8'));
@@ -130,12 +129,10 @@ class AppProxy {
130
129
  })
131
130
  .then((cookie) => {
132
131
  this.loginCookie.setValue(cookie);
133
- (0, undici_1.request)(new url_1.URL('/', this.target).href, {
132
+ globalAxios_1.default.get(new url_1.URL('/', this.target).href, {
134
133
  headers: this.combinedHeader({ cookie }),
135
- }).then(({ body }) => {
136
- body.text().then((data) => {
137
- SDF = JSON.parse(parse_SDF(data));
138
- });
134
+ }).then(({ data: pageHtml }) => {
135
+ SDF = JSON.parse(parse_SDF(pageHtml));
139
136
  });
140
137
  this.spinnies.succeed('login');
141
138
  })
@@ -204,7 +201,8 @@ class AppProxy {
204
201
  if (!this.isMainApp && !isApiBelongMainApp.includes(req.url)) {
205
202
  const apiPathMatchReg = /\/(:[^/]+|\$?{[^/]+})/g;
206
203
  const apis = mf.apis || [];
207
- if (!(req === null || req === void 0 ? void 0 : req.headers['micro-app-id'].includes('main-app'))) {
204
+ const microAppId = req.headers['micro-app-id'];
205
+ if (microAppId && !microAppId.includes('main-app')) {
208
206
  const method = (req === null || req === void 0 ? void 0 : req.method) || 'GET';
209
207
  const urlPath = ((_b = req === null || req === void 0 ? void 0 : req.path) === null || _b === void 0 ? void 0 : _b.replace(/^\s*\/(custom-api|open-api)/, '')) || '';
210
208
  let isExists = false;
@@ -4,7 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const axios_1 = __importDefault(require("axios"));
7
- const globalAxios = axios_1.default.create();
7
+ const https_1 = __importDefault(require("https"));
8
+ const globalAxios = axios_1.default.create({
9
+ httpsAgent: new https_1.default.Agent({
10
+ rejectUnauthorized: false
11
+ }),
12
+ });
8
13
  globalAxios.interceptors.request.use(function (config) {
9
14
  return config;
10
15
  }, function (error) {
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ export interface Config extends AppProxyConfig {
4
4
  [key: string]: any;
5
5
  };
6
6
  }
7
+ export { default as globalAxios } from './globalAxios';
8
+ export { default as AppProxy } from './appProxy';
7
9
  export { GSdf } from './appProxy';
8
10
  export declare function awaiting(): any[];
9
11
  export default function createProxy({ additionHeaders, ...restPrevConfig }: Config): (app: any) => void;
package/dist/index.js CHANGED
@@ -14,12 +14,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.awaiting = exports.GSdf = void 0;
17
+ exports.awaiting = exports.GSdf = exports.AppProxy = exports.globalAxios = void 0;
18
18
  const os_1 = __importDefault(require("os"));
19
19
  const http_proxy_middleware_1 = require("http-proxy-middleware");
20
20
  const appProxy_1 = __importDefault(require("./appProxy"));
21
+ var globalAxios_1 = require("./globalAxios");
22
+ Object.defineProperty(exports, "globalAxios", { enumerable: true, get: function () { return __importDefault(globalAxios_1).default; } });
21
23
  var appProxy_2 = require("./appProxy");
22
- Object.defineProperty(exports, "GSdf", { enumerable: true, get: function () { return appProxy_2.GSdf; } });
24
+ Object.defineProperty(exports, "AppProxy", { enumerable: true, get: function () { return __importDefault(appProxy_2).default; } });
25
+ var appProxy_3 = require("./appProxy");
26
+ Object.defineProperty(exports, "GSdf", { enumerable: true, get: function () { return appProxy_3.GSdf; } });
23
27
  function awaiting() {
24
28
  let $resolve, $reject;
25
29
  const waiting = new Promise((resolve, reject) => {
@@ -43,6 +47,7 @@ function createProxy(_a) {
43
47
  });
44
48
  app.use(needProxyApi, (0, http_proxy_middleware_1.createProxyMiddleware)({
45
49
  target: appProxyConfig.target,
50
+ secure: false,
46
51
  changeOrigin: true,
47
52
  selfHandleResponse: true,
48
53
  onProxyReq: appProxy.processReq.bind(appProxy),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-proxy",
3
- "version": "3.2.3",
3
+ "version": "3.2.5",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -15,8 +15,7 @@
15
15
  "fs-extra": "10.0.1",
16
16
  "http-proxy-middleware": "2.0.4",
17
17
  "js-sha256": "0.9.0",
18
- "spinnies": "^0.5.1",
19
- "undici": "^5.20.0"
18
+ "spinnies": "^0.5.1"
20
19
  },
21
20
  "devDependencies": {
22
21
  "@types/fs-extra": "9.0.13",