@tuya-sat/micro-dev-proxy 0.0.1-beta → 0.0.1-beta.3

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/README.md CHANGED
@@ -1,12 +1,48 @@
1
- ## 🔧下载
1
+ <div id="top"></div>
2
+ <br />
3
+ <div align="center">
4
+ <a href="https://github.com/othneildrew/Best-README-Template">
5
+ <img src="https://images.tuyacn.com/rms-static/da7f7ac0-3e0c-11ec-89bb-d7b7de210e4b-1636098546797.png" alt="Logo" width="80" height="80">
6
+ </a>
2
7
 
3
- ```shell
4
- yarn add @tuya-sat/micro-dev-proxy --dev
5
- ```
6
- ## 🚰引用
8
+ <h3 align="center">Saturn - micro-dev-proxy</h3>
9
+
10
+ <p align="center">
11
+ 用于微应用本地联调
12
+ <br/>
13
+ <a href="https://github.com/tuya-sat/discuss">土星项目</a>
14
+ ·
15
+ <a href="https://github.com/tuya-sat/discuss/issues">报告问题</a>
16
+ ·
17
+ <a href="https://github.com/tuya-sat/discuss/issues">提交需求</a>
18
+ </p>
19
+ </div>
20
+
21
+ ## 介绍
22
+ 基于http-proxy-middleware实现模拟登录态及接口转发
7
23
 
8
- ```js
9
- const createProxy = require("@tuya-sat/micro-dev-proxy").default
24
+ ## 安装
25
+
26
+ ```sh
27
+ yarn add @tuya-sat/micro-dev-proxy -D
10
28
  ```
11
29
 
12
- ## 💡用法
30
+ ## 使用
31
+ 该包主要被[@tuya-sat/micro-script](https://www.npmjs.com/package/@tuya-sat/micro-script)使用
32
+
33
+ ## 资源工具
34
+
35
+ * [@tuya-sat/components](https://www.npmjs.com/package/@tuya-sat/components)
36
+ * [@tuya-sat/sdf-cli](https://www.npmjs.com/package/@tuya-sat/sdf-cli)
37
+ * [@tuya-sat/create-micro-app](https://www.npmjs.com/package/@tuya-sat/create-micro-app)
38
+ * [@tuya-sat/micro-script](https://www.npmjs.com/package/@tuya-sat/micro-script)
39
+
40
+
41
+ ## License
42
+
43
+ MIT
44
+
45
+ ## 联系我们
46
+
47
+ 欢迎在 [https://github.com/tuya-sat/discuss/issues](https://github.com/tuya-sat/discuss/issues) 向我们提交反馈
48
+
@@ -4,7 +4,7 @@ export interface AppProxyConfig {
4
4
  target: string;
5
5
  username: string;
6
6
  password: string;
7
- csrf: boolean;
7
+ csrf?: boolean;
8
8
  loginApi?: string;
9
9
  additionHeaders?: {
10
10
  [key: string]: any;
package/dist/appProxy.js CHANGED
@@ -37,6 +37,7 @@ const csrf_1 = __importStar(require("./csrf"));
37
37
  const initLogin_1 = __importStar(require("./initLogin"));
38
38
  const token_1 = __importDefault(require("./token"));
39
39
  const util_1 = require("./util");
40
+ const url_1 = require("url");
40
41
  class AppProxy {
41
42
  constructor({ target, username, password, additionHeaders, isMainApp, loginApi, csrf = true, logSign, }) {
42
43
  this.loginCookie = new token_1.default();
@@ -63,6 +64,7 @@ class AppProxy {
63
64
  yield this.getLoginCookie();
64
65
  });
65
66
  }
67
+ //获取csrf
66
68
  getCsrf() {
67
69
  return __awaiter(this, void 0, void 0, function* () {
68
70
  yield (0, csrf_1.default)(this.target)
@@ -76,9 +78,11 @@ class AppProxy {
76
78
  });
77
79
  });
78
80
  }
81
+ //模拟登录
79
82
  getLoginCookie() {
80
83
  return __awaiter(this, void 0, void 0, function* () {
81
- yield (0, initLogin_1.default)(this.target + this.loginApi, { username: this.username, password: this.password }, {
84
+ const { href: loginUrl } = new url_1.URL(this.loginApi, this.target);
85
+ yield (0, initLogin_1.default)(loginUrl, { username: this.username, password: this.password }, {
82
86
  headers: this.combinedHeader({ cookie: this.csrfCookie.value }),
83
87
  })
84
88
  .then((cookie) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-proxy",
3
- "version": "0.0.1-beta",
3
+ "version": "0.0.1-beta.3",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {