@hieuzest/koishi-plugin-riichi-city 0.5.4 → 0.5.6
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 +3 -3
- package/lib/api.js +10 -6
- package/lib/index.js +2 -1
- package/package.json +4 -1
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:
|
|
17
|
-
decrypt(data: 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.
|
|
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
|
|
154
|
-
|
|
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/lib/index.js
CHANGED
|
@@ -49,6 +49,7 @@ var import_api2 = require("./api");
|
|
|
49
49
|
|
|
50
50
|
// src/dhs.ts
|
|
51
51
|
var import_koishi = require("koishi");
|
|
52
|
+
var import_koishi_utils = require("@hieuzest/koishi-utils");
|
|
52
53
|
var import_lobby = require("./lobby");
|
|
53
54
|
var RiichiCityDHS = class extends import_koishi.Service {
|
|
54
55
|
constructor(ctx, config) {
|
|
@@ -241,7 +242,7 @@ ${config.extraHelp}`.trim();
|
|
|
241
242
|
if (!contestId) return;
|
|
242
243
|
if (!this.checkPermission(session)) return;
|
|
243
244
|
args = import_koishi.h.unescape(args);
|
|
244
|
-
const argsList =
|
|
245
|
+
const argsList = (0, import_koishi_utils.splitBackslashEscapedArgs)(args);
|
|
245
246
|
const players = [];
|
|
246
247
|
const c = await this.getDHS(contestId);
|
|
247
248
|
if (!c) return "大会室未找到";
|
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
|
+
"version": "0.5.6",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"koishi": "^4.17.8"
|
|
28
28
|
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@hieuzest/koishi-utils": "^1.0.0"
|
|
31
|
+
},
|
|
29
32
|
"koishi": {
|
|
30
33
|
"service": {
|
|
31
34
|
"implements": [
|