@hieuzest/koishi-plugin-riichi-city 0.5.4 → 0.5.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/lib/api.d.ts CHANGED
@@ -12,9 +12,9 @@ interface Cipher<S = any, T = any> {
12
12
  decrypt(data: T): S;
13
13
  }
14
14
  declare namespace Cipher {
15
- class NoneCipher implements Cipher {
16
- encrypt(data: any): any;
17
- decrypt(data: string): string;
15
+ class NoneCipher<S> implements Cipher<S, string> {
16
+ encrypt(data: S): string;
17
+ decrypt(data: string): S;
18
18
  }
19
19
  class Aes128CbcCipher<S> implements Cipher<S, string> {
20
20
  private key;
package/lib/api.js CHANGED
@@ -68,10 +68,10 @@ var Cipher;
68
68
  __name(this, "NoneCipher");
69
69
  }
70
70
  encrypt(data) {
71
- return data;
71
+ return JSON.stringify(data);
72
72
  }
73
73
  decrypt(data) {
74
- return data;
74
+ return JSON.parse(data);
75
75
  }
76
76
  }
77
77
  Cipher2.NoneCipher = NoneCipher;
@@ -85,7 +85,7 @@ var Cipher;
85
85
  }
86
86
  encrypt(data) {
87
87
  const cipher = crypto.createCipheriv("aes-256-cbc", this.key, this.iv);
88
- return Buffer.concat([cipher.update(JSON.stringify(data)), cipher.final()]).toString("base64");
88
+ return Buffer.concat([cipher.update(Buffer.from(JSON.stringify(data))), cipher.final()]).toString("base64");
89
89
  }
90
90
  decrypt(data) {
91
91
  const cipher = crypto.createDecipheriv("aes-256-cbc", this.key, this.iv);
@@ -136,7 +136,7 @@ var RiichiCityApi = class _RiichiCityApi {
136
136
  cipher;
137
137
  user;
138
138
  _update() {
139
- this.headers.cookies = this.config.cipherType === "none" ? JSON.stringify(this.cookie) : this.cipher.encrypt(this.cookie);
139
+ this.headers.cookies = this.cipher.encrypt(this.cookie);
140
140
  this.http.config.headers = this.headers;
141
141
  }
142
142
  _handleError(res) {
@@ -150,8 +150,12 @@ var RiichiCityApi = class _RiichiCityApi {
150
150
  this._update();
151
151
  path = "/";
152
152
  }
153
- return await this.http.post(path, this.cipher.encrypt(data)).then((res) => {
154
- res = this.cipher.decrypt(res);
153
+ return await this.http("POST", path, {
154
+ data: this.cipher.encrypt(data),
155
+ responseType: "text",
156
+ proxyAgent: void 0
157
+ }).then((resp) => {
158
+ const res = this.cipher.decrypt(resp.data);
155
159
  this._handleError(res);
156
160
  return res;
157
161
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hieuzest/koishi-plugin-riichi-city",
3
3
  "description": "",
4
- "version": "0.5.4",
4
+ "version": "0.5.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [