karin-plugin-mys-core 1.0.1 → 1.0.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.
Files changed (168) hide show
  1. package/LICENSE +674 -0
  2. package/lib/apps/MiHoYoLogin.d.ts +3 -1
  3. package/lib/apps/MiHoYoLogin.js +177 -109
  4. package/lib/apps/MysDevice.d.ts +2 -2
  5. package/lib/apps/MysDevice.js +65 -23
  6. package/lib/apps/UIDManage.d.ts +10 -0
  7. package/lib/apps/UIDManage.js +52 -0
  8. package/lib/array-DuqoS2wx.d.ts +62 -0
  9. package/lib/chunk-2DHTKQ34.js +0 -0
  10. package/lib/chunk-3BIQN6QA.js +27 -0
  11. package/lib/chunk-5NA7ZPDS.js +54 -0
  12. package/lib/chunk-6PIXUPZ6.js +82 -0
  13. package/lib/chunk-7KEG6SDX.js +0 -0
  14. package/lib/chunk-7SZX3RBZ.js +0 -0
  15. package/lib/chunk-7VAWV6ZE.js +0 -0
  16. package/lib/chunk-7WESXE4X.js +29 -0
  17. package/lib/chunk-ARLTXJFJ.js +0 -0
  18. package/lib/chunk-CFS2WFOO.js +0 -0
  19. package/lib/chunk-COKAJ7V6.js +31 -0
  20. package/lib/chunk-EMAUATE3.js +217 -0
  21. package/lib/chunk-FBWSEBAW.js +0 -0
  22. package/lib/chunk-FOAQZIZ2.js +0 -0
  23. package/lib/chunk-G547WVGV.js +73 -0
  24. package/lib/chunk-G5W5WAY5.js +64 -0
  25. package/lib/chunk-HNODD2IL.js +179 -0
  26. package/lib/chunk-HVYNK5BN.js +45 -0
  27. package/lib/chunk-I7XZONDN.js +13 -0
  28. package/lib/chunk-IVZICDGW.js +19 -0
  29. package/lib/chunk-JKZ5NRPX.js +130 -0
  30. package/lib/chunk-JRH4JC43.js +0 -0
  31. package/lib/chunk-JVJQKRJ4.js +89 -0
  32. package/lib/chunk-K5U2O3HH.js +0 -0
  33. package/lib/chunk-KN5SHBVI.js +30 -0
  34. package/lib/chunk-LG34FPBI.js +50 -0
  35. package/lib/chunk-LJSDSOY6.js +0 -0
  36. package/lib/chunk-LYTNREAI.js +0 -0
  37. package/lib/chunk-MWYDWDR4.js +0 -0
  38. package/lib/chunk-RWBRS7SA.js +510 -0
  39. package/lib/chunk-SEWEEPJN.js +0 -0
  40. package/lib/{chunk-JML6VYXN.js → chunk-SHLPPEAY.js} +13 -17
  41. package/lib/chunk-SHW6FHIB.js +10 -0
  42. package/lib/chunk-UVMX6WUC.js +38 -0
  43. package/lib/chunk-W4DBT7AD.js +0 -0
  44. package/lib/chunk-XQWTJIT4.js +0 -0
  45. package/lib/chunk-Y3J3J5B2.js +124 -0
  46. package/lib/chunk-Z5I6A73Y.js +0 -0
  47. package/lib/common-Dw5l6Uud.d.ts +33 -0
  48. package/lib/define-BWuQ7acM.d.ts +131 -0
  49. package/lib/dir.d.ts +11 -13
  50. package/lib/dir.js +1 -1
  51. package/lib/exports/config/array.d.ts +1 -0
  52. package/lib/exports/config/array.js +7 -0
  53. package/lib/exports/config/config.d.ts +1 -0
  54. package/lib/exports/config/config.js +8 -0
  55. package/lib/exports/config/index.d.ts +2 -0
  56. package/lib/exports/config/index.js +14 -0
  57. package/lib/exports/config/types/config.d.ts +12 -0
  58. package/lib/exports/config/types/config.js +1 -0
  59. package/lib/exports/config/types/index.d.ts +1 -0
  60. package/lib/exports/config/types/index.js +2 -0
  61. package/lib/exports/database/database.d.ts +30 -0
  62. package/lib/exports/database/database.js +18 -0
  63. package/lib/exports/database/dbs/base.d.ts +23 -0
  64. package/lib/exports/database/dbs/base.js +15 -0
  65. package/lib/exports/database/dbs/index.d.ts +4 -0
  66. package/lib/exports/database/dbs/index.js +23 -0
  67. package/lib/exports/database/dbs/sqlite3.d.ts +23 -0
  68. package/lib/exports/database/dbs/sqlite3.js +19 -0
  69. package/lib/exports/database/dbs/table.d.ts +13 -0
  70. package/lib/exports/database/dbs/table.js +19 -0
  71. package/lib/exports/database/index.d.ts +12 -0
  72. package/lib/exports/database/index.js +62 -0
  73. package/lib/exports/database/tables/index.d.ts +9 -0
  74. package/lib/exports/database/tables/index.js +39 -0
  75. package/lib/exports/database/tables/mysAccountInfo.d.ts +9 -0
  76. package/lib/exports/database/tables/mysAccountInfo.js +23 -0
  77. package/lib/exports/database/tables/mysDeviceInfo.d.ts +9 -0
  78. package/lib/exports/database/tables/mysDeviceInfo.js +26 -0
  79. package/lib/exports/database/tables/mysUserInfo.d.ts +9 -0
  80. package/lib/exports/database/tables/mysUserInfo.js +23 -0
  81. package/lib/exports/database/types/database.d.ts +6 -0
  82. package/lib/exports/database/types/database.js +1 -0
  83. package/lib/exports/database/types/dbs/base.d.ts +114 -0
  84. package/lib/exports/database/types/dbs/base.js +11 -0
  85. package/lib/exports/database/types/dbs/index.d.ts +2 -0
  86. package/lib/exports/database/types/dbs/index.js +12 -0
  87. package/lib/exports/database/types/index.d.ts +6 -0
  88. package/lib/exports/database/types/index.js +24 -0
  89. package/lib/exports/database/types/tables/index.d.ts +5 -0
  90. package/lib/exports/database/types/tables/index.js +13 -0
  91. package/lib/exports/database/types/tables/mysAccountInfo.d.ts +14 -0
  92. package/lib/exports/database/types/tables/mysAccountInfo.js +7 -0
  93. package/lib/exports/database/types/tables/mysDeviceInfo.d.ts +19 -0
  94. package/lib/exports/database/types/tables/mysDeviceInfo.js +1 -0
  95. package/lib/exports/database/types/tables/mysUserInfo.d.ts +31 -0
  96. package/lib/exports/database/types/tables/mysUserInfo.js +7 -0
  97. package/lib/exports/mys/api/apis.d.ts +82 -0
  98. package/lib/exports/mys/api/apis.js +57 -0
  99. package/lib/exports/mys/api/app.d.ts +60 -0
  100. package/lib/exports/mys/api/app.js +31 -0
  101. package/lib/exports/mys/api/define.d.ts +6 -0
  102. package/lib/exports/mys/api/define.js +43 -0
  103. package/lib/exports/mys/api/index.d.ts +11 -0
  104. package/lib/exports/mys/api/index.js +64 -0
  105. package/lib/exports/mys/index.d.ts +13 -0
  106. package/lib/exports/mys/index.js +77 -0
  107. package/lib/exports/mys/types/api/define.d.ts +6 -0
  108. package/lib/exports/mys/types/api/define.js +1 -0
  109. package/lib/exports/mys/types/api/index.d.ts +6 -0
  110. package/lib/exports/mys/types/api/index.js +2 -0
  111. package/lib/exports/mys/types/index.d.ts +10 -0
  112. package/lib/exports/mys/types/index.js +12 -0
  113. package/lib/exports/mys/types/user/game.d.ts +10 -0
  114. package/lib/exports/mys/types/user/game.js +1 -0
  115. package/lib/exports/mys/types/user/index.d.ts +10 -0
  116. package/lib/exports/mys/types/user/index.js +9 -0
  117. package/lib/exports/mys/types/user/userInfo.d.ts +10 -0
  118. package/lib/exports/mys/types/user/userInfo.js +7 -0
  119. package/lib/exports/mys/user/deviceInfo.d.ts +11 -0
  120. package/lib/exports/mys/user/deviceInfo.js +29 -0
  121. package/lib/exports/mys/user/game.d.ts +20 -0
  122. package/lib/exports/mys/user/game.js +7 -0
  123. package/lib/exports/mys/user/index.d.ts +12 -0
  124. package/lib/exports/mys/user/index.js +51 -0
  125. package/lib/exports/mys/user/userInfo.d.ts +10 -0
  126. package/lib/exports/mys/user/userInfo.js +45 -0
  127. package/lib/exports/utils/common.d.ts +1 -0
  128. package/lib/exports/utils/common.js +13 -0
  129. package/lib/exports/utils/index.d.ts +2 -0
  130. package/lib/exports/utils/index.js +12 -0
  131. package/lib/exports/utils/render.d.ts +21 -0
  132. package/lib/exports/utils/render.js +7 -0
  133. package/lib/index-DEEWbZ0V.d.ts +102 -0
  134. package/lib/index.js +1 -1
  135. package/package.json +29 -15
  136. package/resources/fonts/HYWenHei-55W.ttf +0 -0
  137. package/resources/image/launcher-icon//345/216/237/347/245/236.png +0 -0
  138. package/resources/image/launcher-icon//345/264/251/345/235/2173.png +0 -0
  139. package/resources/image/launcher-icon//345/264/251/345/235/217/345/255/246/345/233/2552.png +0 -0
  140. package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/345/233/240/347/274/230/347/262/276/347/201/265.png +0 -0
  141. package/resources/image/launcher-icon//345/264/251/345/235/217/357/274/232/346/230/237/347/251/271/351/223/201/351/201/223.png +0 -0
  142. package/resources/image/launcher-icon//346/230/237/345/270/203/350/260/267/345/234/260.png +0 -0
  143. package/resources/image/launcher-icon//346/234/252/345/256/232/344/272/213/344/273/266/347/260/277.png +0 -0
  144. package/resources/image/launcher-icon//347/273/235/345/214/272/351/233/266.png +0 -0
  145. package/resources/image/mys-logo.png +0 -0
  146. package/resources/template/ShowBindAccount/index.css +1 -0
  147. package/resources/template/ShowBindAccount/index.html +65 -0
  148. package/resources/template/ShowBindDevice/index.html +20 -0
  149. package/resources/template/ShowBindDevice/inex.css +1 -0
  150. package/resources/template/layout/default.css +1 -0
  151. package/resources/template/layout/default.html +27 -0
  152. package/lib/app.d.ts +0 -2
  153. package/lib/base-BJv9XnQP.d.ts +0 -120
  154. package/lib/chunk-CQNW7LJI.js +0 -38
  155. package/lib/chunk-MV2UE7C7.js +0 -410
  156. package/lib/chunk-NHUNEZXM.js +0 -371
  157. package/lib/chunk-WYRIRWT5.js +0 -213
  158. package/lib/database-byVXw91u.d.ts +0 -5
  159. package/lib/define-pa_pWNWT.d.ts +0 -182
  160. package/lib/exports/core.d.ts +0 -249
  161. package/lib/exports/core.js +0 -45
  162. package/lib/exports/database.d.ts +0 -48
  163. package/lib/exports/database.js +0 -20
  164. package/lib/exports/types.d.ts +0 -5
  165. package/lib/exports/types.js +0 -13
  166. package/lib/index.d.ts +0 -2
  167. package/lib/web.config.d.ts +0 -5
  168. package/lib/web.config.js +0 -55
@@ -1,410 +0,0 @@
1
- import {
2
- MysAccountInfoDB,
3
- MysDeviceInfoDB,
4
- MysUserInfoDB
5
- } from "./chunk-NHUNEZXM.js";
6
- import {
7
- common_exports
8
- } from "./chunk-WYRIRWT5.js";
9
-
10
- // src/core/api/mysApp.ts
11
- var version = { cn: "2.70.1", os: "1.5.0" };
12
- var appId = 2;
13
- var salt = {
14
- os: "6cqshh5dhw73bzxn20oexa9k516chk7s",
15
- "4X": "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
16
- "6X": "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
17
- K2: "S9Hrn38d2b55PamfIR9BNA3Tx9sQTOem",
18
- LK2: "sjdNFJB7XxyDWGIAk0eTV8AOCfMJmyEo",
19
- PROD: "JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS"
20
- };
21
- var MysApp = Object.freeze({
22
- version,
23
- appId,
24
- salt
25
- });
26
-
27
- // src/core/api/define.ts
28
- import md5 from "md5";
29
- import { logger } from "node-karin";
30
- import axios, { AxiosHeaders } from "node-karin/axios";
31
- import lodash from "node-karin/lodash";
32
- var DefineMysApi = class {
33
- uidInfo;
34
- #apiInfo;
35
- #needDeviceFp = false;
36
- #needCheckCode = false;
37
- constructor(apiInfo, uidInfo, opt = {}) {
38
- this.#apiInfo = apiInfo;
39
- this.uidInfo = uidInfo;
40
- this.#needDeviceFp = !!opt.deviceFp;
41
- this.#needCheckCode = !!opt.checkCode;
42
- }
43
- get isHoyolab() {
44
- return this.uidInfo.type === "hoyolab" /* os */;
45
- }
46
- async getApi(data) {
47
- const { Method, Url, Body, HeaderFn } = this.#apiInfo(this, data);
48
- const Headers = new AxiosHeaders(await HeaderFn({
49
- query: Url.search.substring(1),
50
- body: Body
51
- }, data));
52
- return {
53
- Method,
54
- Url,
55
- Body,
56
- Headers
57
- };
58
- }
59
- async getDevice() {
60
- if (this.Device) return this.Device;
61
- this.Device = {
62
- id: common_exports.getDeviceGuid(),
63
- name: `Karin-${common_exports.randomString(8, "All")}`
64
- };
65
- return this.Device;
66
- }
67
- async request(data, checkCode = true) {
68
- const { Method, Url, Body, HeaderFn } = this.#apiInfo(this, data);
69
- const Headers = new AxiosHeaders(await HeaderFn({
70
- query: Url.search.substring(1),
71
- body: Body
72
- }, data));
73
- if (this.#needDeviceFp) {
74
- Headers.set();
75
- }
76
- const params = {
77
- url: Url.href,
78
- method: Method,
79
- data: Body,
80
- headers: Headers
81
- };
82
- const start = Date.now();
83
- let response;
84
- try {
85
- if (Method === "GET") {
86
- response = await axios.get(params.url, {
87
- headers: params.headers
88
- });
89
- } else if (Method === "POST") {
90
- response = await axios.post(params.url, params.data, {
91
- headers: params.headers
92
- });
93
- } else {
94
- response = axios.request(params);
95
- }
96
- } catch (err) {
97
- logger.debug(`mys-core-requst[${logger.green(`${Date.now() - start}ms`)}]: ${JSON.stringify(params, null, 2)}`);
98
- return response;
99
- }
100
- const res = response.data;
101
- logger.debug(`mys-core-requst[${logger.green(`${Date.now() - start}ms`)}]: ${JSON.stringify(params, null, 2)} -> ${JSON.stringify(res, null, 2)}`);
102
- if (!res) {
103
- return void 0;
104
- }
105
- if ("retcode" in res) {
106
- res.retcode = Number(res.retcode);
107
- }
108
- if (this.#needCheckCode && checkCode) {
109
- return await this.checkRetCode(res, data);
110
- }
111
- return res;
112
- }
113
- async checkRetCode(res, data, validate = true) {
114
- return res;
115
- }
116
- getDS1(saltKey, query = "", body = "") {
117
- const r = common_exports.randomString(6, "All");
118
- const t = Math.floor(Date.now() / 1e3);
119
- let DS = `salt=${MysApp.salt[saltKey]}&t=${t}&r=${r}`;
120
- if (query || body) DS += `&b=${body}&q=${query}`;
121
- return `${t},${r},${md5(DS)}`;
122
- }
123
- getDS2(saltKey, query = "", body = "") {
124
- const r = lodash.random(100001, 2e5);
125
- const t = Math.floor(Date.now() / 1e3);
126
- return `${t},${r},${md5(`salt=${MysApp.salt[saltKey]}&t=${t}&r=${r}&b=${body}&q=${query}`)}`;
127
- }
128
- NoHeaders = (options = {}) => ({});
129
- BaseCnHeaders = async () => {
130
- await this.getDevice();
131
- return {
132
- "x-rpc-app_version": MysApp.version.cn,
133
- "x-rpc-client_type": "5",
134
- "x-rpc-device_id": this.Device.id,
135
- "User-Agent": `Mozilla/5.0 (Linux; Android 12; ${this.Device.name}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36 miHoYoBBS/${MysApp.version.cn}`,
136
- Referer: "https://webstatic.mihoyo.com"
137
- };
138
- };
139
- BaseOsHeaders = () => ({
140
- "x-rpc-app_version": MysApp.version.cn,
141
- "x-rpc-client_type": "4",
142
- "x-rpc-language": "zh-cn"
143
- });
144
- PassportHeaders = (options = {}) => ({
145
- "x-rpc-app_version": MysApp.version.cn,
146
- "x-rpc-game_biz": "bbs_cn",
147
- "x-rpc-client_type": "2",
148
- "User-Agent": "okhttp/4.8.0",
149
- "x-rpc-app_id": "bll8iq97cem8",
150
- DS: this.getDS1("PROD", options.query, JSON.stringify(options.body))
151
- });
152
- CookieHeaders = (options = {}) => ({
153
- Cookie: this.uidInfo.cookie,
154
- ...this[this.isHoyolab ? "BaseOsHeaders" : "BaseCnHeaders"]()
155
- });
156
- };
157
-
158
- // src/core/api/mysHosts.ts
159
- var MysHosts = Object.freeze({
160
- bbs: {
161
- ["mihoyo" /* cn */]: "https://bbs-api.miyoushe.com/",
162
- ["hoyolab" /* os */]: "https://bbs-api-os.mihoyo.com/"
163
- },
164
- web: {
165
- ["mihoyo" /* cn */]: "https://api-takumi.mihoyo.com/",
166
- ["hoyolab" /* os */]: "https://api-os-takumi.mihoyo.com/",
167
- /** new web host */
168
- miyoushe: "https://api-takumi.miyoushe.com/"
169
- },
170
- static: "https://api-takumi-static.mihoyo.com/",
171
- record: {
172
- ["mihoyo" /* cn */]: "https://api-takumi-record.mihoyo.com/",
173
- ["hoyolab" /* os */]: "https://bbs-api-os.mihoyo.com/"
174
- },
175
- hk4e: {
176
- ["mihoyo" /* cn */]: "https://hk4e-api.mihoyo.com/",
177
- ["hoyolab" /* os */]: "https://hk4e-api-os.hoyoverse.com/"
178
- },
179
- hk4eGacha: "https://public-operation-hk4e.mihoyo.com/",
180
- hk4eSdk: "https://hk4e-sdk.mihoyo.com/",
181
- napGacha: {
182
- ["mihoyo" /* cn */]: "https://public-operation-nap.mihoyo.com/",
183
- ["hoyolab" /* os */]: "https://public-operation-nap-sg.hoyoverse.com/"
184
- },
185
- publicData: {
186
- ["mihoyo" /* cn */]: "https://public-data-api.mihoyo.com/",
187
- ["hoyolab" /* os */]: "https://sg-public-data-api.hoyoverse.com/"
188
- },
189
- napAct: {
190
- ["mihoyo" /* cn */]: "https://act-nap-api.mihoyo.com/",
191
- ["hoyolab" /* os */]: "https://sg-act-nap-api.mihoyo.com/"
192
- },
193
- passport: "https://passport-api.mihoyo.com/",
194
- hk4eSg: {
195
- ["hoyolab" /* os */]: "https://sg-hk4e-api.hoyolab.com/"
196
- },
197
- publicSg: {
198
- ["hoyolab" /* os */]: "https://sg-public-api.hoyolab.com/",
199
- hoyoverse: "https://sg-public-api.hoyoverse.com/"
200
- }
201
- });
202
-
203
- // src/core/api/mysApis.ts
204
- var fetchQRcode = () => new DefineMysApi(
205
- (self, data) => ({
206
- Method: "POST",
207
- Url: new URL(`${MysHosts.hk4eSdk}hk4e_cn/combo/panda/qrcode/fetch`),
208
- Body: {
209
- app_id: MysApp.appId,
210
- device: data.device
211
- },
212
- HeaderFn: self.NoHeaders
213
- })
214
- );
215
- var queryQRcode = () => new DefineMysApi((self, data) => ({
216
- Method: "POST",
217
- Url: new URL(`${MysHosts.hk4eSdk}hk4e_cn/combo/panda/qrcode/query`),
218
- Body: {
219
- app_id: MysApp.appId,
220
- device: data.device,
221
- ticket: data.ticket
222
- },
223
- HeaderFn: self.NoHeaders
224
- }));
225
- var getTokenByGameToken = () => new DefineMysApi((self, data) => ({
226
- Method: "POST",
227
- Url: new URL(`${MysHosts.passport}account/ma-cn-session/app/getTokenByGameToken`),
228
- Body: {
229
- account_id: data.account_id,
230
- game_token: data.game_token
231
- },
232
- HeaderFn: self.PassportHeaders
233
- }));
234
- var getCookieAccountInfoByGameToken = () => new DefineMysApi((self, data) => ({
235
- Method: "GET",
236
- Url: new URL(`${MysHosts.web["mihoyo" /* cn */]}auth/api/getCookieAccountInfoByGameToken?account_id=${data.account_id}&game_token=${data.game_token}`),
237
- HeaderFn: self.NoHeaders
238
- }));
239
- var getCookieTokenBySToken = (method) => new DefineMysApi((self, data) => ({
240
- Method: method,
241
- Url: function() {
242
- const url = new URL(`${MysHosts.web["mihoyo" /* cn */]}auth/api/getCookieAccountInfoBySToken?game_biz=hk4e_cn&${data.stoken}`);
243
- if (self.isHoyolab) {
244
- url.searchParams.set("game_biz", "hk4e_global");
245
- url.host = MysHosts.web["hoyolab" /* os */].replace(/^https?:\/\//, "");
246
- }
247
- return url;
248
- }(),
249
- HeaderFn: self.NoHeaders
250
- }));
251
- var getUserGameRolesByCookie = (uidInfo) => new DefineMysApi((self, data) => ({
252
- Method: "GET",
253
- Url: new URL(`${MysHosts.web[self.isHoyolab ? "hoyolab" /* os */ : "mihoyo" /* cn */]}binding/api/getUserGameRolesByCookie`),
254
- HeaderFn: self.CookieHeaders
255
- }), uidInfo);
256
- var getUserFullInfo = (uidInfo) => new DefineMysApi((self, data) => ({
257
- Method: "GET",
258
- Url: new URL(`${MysHosts.web.miyoushe}user/wapi/getUserFullInfo?gids=2`),
259
- HeaderFn: self.CookieHeaders
260
- }), uidInfo);
261
-
262
- // src/core/user/deviceInfo.ts
263
- import md52 from "md5";
264
- import lodash2 from "node-karin/lodash";
265
- var DeviceInfo2 = class {
266
- static async get(Md5) {
267
- return await MysDeviceInfoDB.findByPk(Md5);
268
- }
269
- static async create(UserInfo2, deviceInfo) {
270
- const deviceMd5 = md52([
271
- UserInfo2.userId,
272
- deviceInfo.deviceId || "",
273
- deviceInfo.name || "",
274
- deviceInfo.board || "",
275
- deviceInfo.model || "",
276
- deviceInfo.oaid || "",
277
- deviceInfo.androidVersion || "",
278
- deviceInfo.fingerprint || "",
279
- deviceInfo.product || ""
280
- ].join("_"));
281
- const MysDeviceInfo = await MysDeviceInfoDB.findByPk(deviceMd5, true);
282
- await MysDeviceInfo.save(deviceInfo);
283
- await UserInfo2.saveUserInfo({
284
- deviceList: lodash2.uniq([...UserInfo2.deviceList, deviceMd5])
285
- });
286
- }
287
- };
288
-
289
- // src/core/user/userInfo.ts
290
- var BaseUserInfo = class {
291
- userId;
292
- #ltuids = [];
293
- #stuids = [];
294
- #deviceList = [];
295
- #ltuidMap = /* @__PURE__ */ new Map();
296
- constructor(userId) {
297
- this.userId = userId;
298
- }
299
- get ltuids() {
300
- return [...this.#ltuids];
301
- }
302
- get stuids() {
303
- return [...this.#stuids];
304
- }
305
- get deviceList() {
306
- return [...this.#deviceList];
307
- }
308
- async initMysAccountInfo(UserInfo2) {
309
- this.UserInfo = UserInfo2;
310
- const { ltuids, stuids } = UserInfo2;
311
- this.#ltuidMap.clear();
312
- this.#ltuids = ltuids;
313
- this.#stuids = stuids;
314
- const idList = Array.from(/* @__PURE__ */ new Set([...ltuids, ...stuids]));
315
- const MysAccountInfoList = await MysAccountInfoDB.findAllByPks(idList);
316
- MysAccountInfoList.forEach((MysAccountInfo) => {
317
- this.#ltuidMap.set(MysAccountInfo.ltuid, MysAccountInfo);
318
- });
319
- }
320
- getLtuidInfo(ltuid) {
321
- return Object.freeze(this.#ltuidMap.get(ltuid));
322
- }
323
- getLtuidInfoList() {
324
- return Array.from(this.#ltuidMap.values()).map((info) => Object.freeze(info));
325
- }
326
- async getDeviceList() {
327
- return await MysDeviceInfoDB.findAllByPks(this.#deviceList);
328
- }
329
- async saveUserInfo(data) {
330
- await this.UserInfo.save(data);
331
- }
332
- async saveMysAccountInfo(ltuid, data) {
333
- let MysAccountInfo = this.#ltuidMap.get(ltuid);
334
- if (!MysAccountInfo) {
335
- MysAccountInfo = await MysAccountInfoDB.findByPk(ltuid, true);
336
- }
337
- await MysAccountInfo.save(data);
338
- this.#ltuidMap.set(ltuid, { ...MysAccountInfo, ...data });
339
- }
340
- };
341
- var refreshUidFnMap = /* @__PURE__ */ new Map();
342
- var UserInfo = class extends BaseUserInfo {
343
- static async create(userId) {
344
- const userInfo = new BaseUserInfo(userId);
345
- userInfo.refresh = async () => {
346
- const UserInfoData = await MysUserInfoDB.findByPk(userId, true);
347
- await userInfo.initMysAccountInfo(UserInfoData);
348
- return userInfo;
349
- };
350
- return await userInfo.refresh();
351
- }
352
- static async refreshCookie(stokenParams, serv) {
353
- const res = await getCookieTokenBySToken(
354
- serv === "mihoyo" /* cn */ ? "GET" : "POST"
355
- ).request({
356
- stoken: new URLSearchParams({
357
- stoken: stokenParams.stoken,
358
- mid: stokenParams.mid,
359
- uid: stokenParams.stuid
360
- }).toString()
361
- });
362
- const result = { Serv: serv, cookie: "", message: "" };
363
- if (res?.retcode === -100) {
364
- result.message = "\u767B\u5F55\u72B6\u6001\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0#\u626B\u7801\u767B\u5F55\uFF01";
365
- } else if (res?.data?.cookie_token) {
366
- result.cookie = `ltuid=${stokenParams.stuid};ltoken=${stokenParams.stoken};cookie_token=${res.data.cookie_token};account_id=${stokenParams.stuid}`;
367
- } else {
368
- result.message = "\u83B7\u53D6Cookie\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0#\u626B\u7801\u767B\u5F55\uFF01";
369
- }
370
- return result;
371
- }
372
- static refreshUidFn(key, fn) {
373
- refreshUidFnMap.set(key, fn);
374
- }
375
- static refreshUid = async (options) => {
376
- let message = "";
377
- const uidList = { data: {}, names: {} };
378
- if (refreshUidFnMap.size > 0) {
379
- const res = await getUserGameRolesByCookie(options).request({});
380
- if (res?.retcode === 0) {
381
- refreshUidFnMap.forEach((fnc) => fnc(uidList));
382
- } else if (res?.retcode === -100) {
383
- message = "Cookie\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0#\u626B\u7801\u767B\u5F55\u6216#\u5237\u65B0Cookie\uFF01";
384
- } else {
385
- message = res?.message || "\u5237\u65B0UID\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF01";
386
- }
387
- }
388
- return {
389
- Serv: options.type,
390
- uids: uidList,
391
- message
392
- };
393
- };
394
- };
395
-
396
- export {
397
- MysApp,
398
- DefineMysApi,
399
- fetchQRcode,
400
- queryQRcode,
401
- getTokenByGameToken,
402
- getCookieAccountInfoByGameToken,
403
- getCookieTokenBySToken,
404
- getUserGameRolesByCookie,
405
- getUserFullInfo,
406
- MysHosts,
407
- DeviceInfo2 as DeviceInfo,
408
- BaseUserInfo,
409
- UserInfo
410
- };