karin-plugin-mys-core 1.0.0 → 1.0.2

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 +181 -125
  4. package/lib/apps/MysDevice.d.ts +5 -0
  5. package/lib/apps/MysDevice.js +101 -0
  6. package/lib/apps/UIDManage.d.ts +10 -0
  7. package/lib/apps/UIDManage.js +52 -0
  8. package/lib/array-CZDr9qst.d.ts +62 -0
  9. package/lib/chunk-2DHTKQ34.js +0 -0
  10. package/lib/chunk-3BIQN6QA.js +27 -0
  11. package/lib/chunk-3CNBOOKY.js +31 -0
  12. package/lib/chunk-5NA7ZPDS.js +54 -0
  13. package/lib/chunk-6PIXUPZ6.js +82 -0
  14. package/lib/chunk-7KEG6SDX.js +0 -0
  15. package/lib/chunk-7SZX3RBZ.js +0 -0
  16. package/lib/chunk-7VAWV6ZE.js +0 -0
  17. package/lib/chunk-7WESXE4X.js +29 -0
  18. package/lib/chunk-7YZHHLS5.js +130 -0
  19. package/lib/chunk-ARLTXJFJ.js +0 -0
  20. package/lib/chunk-CFS2WFOO.js +0 -0
  21. package/lib/chunk-EMAUATE3.js +217 -0
  22. package/lib/chunk-FBWSEBAW.js +0 -0
  23. package/lib/chunk-FOAQZIZ2.js +0 -0
  24. package/lib/chunk-G547WVGV.js +73 -0
  25. package/lib/chunk-G5W5WAY5.js +64 -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-JBGXPVO2.js +179 -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-QMSYS77M.js +38 -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-W4DBT7AD.js +0 -0
  43. package/lib/chunk-X75DW4KI.js +510 -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 -16
  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/config/config.json +0 -3
  153. package/lib/app.d.ts +0 -2
  154. package/lib/base-B1BvQ4ol.d.ts +0 -99
  155. package/lib/chunk-4JTLXC2G.js +0 -519
  156. package/lib/chunk-7QISGXVH.js +0 -347
  157. package/lib/chunk-JIO4GOQA.js +0 -31
  158. package/lib/database-BDHrI6Vm.d.ts +0 -5
  159. package/lib/define-CrfHwHnK.d.ts +0 -163
  160. package/lib/exports/core.d.ts +0 -228
  161. package/lib/exports/core.js +0 -39
  162. package/lib/exports/database.d.ts +0 -47
  163. package/lib/exports/database.js +0 -17
  164. package/lib/exports/types.d.ts +0 -10
  165. package/lib/exports/types.js +0 -11
  166. package/lib/index.d.ts +0 -2
  167. package/lib/web.config.d.ts +0 -5
  168. package/lib/web.config.js +0 -30
@@ -1,519 +0,0 @@
1
- import {
2
- MysAccountInfoDB,
3
- MysUserInfoDB
4
- } from "./chunk-7QISGXVH.js";
5
- import {
6
- dir
7
- } from "./chunk-JML6VYXN.js";
8
- import {
9
- __export
10
- } from "./chunk-MLKGABMK.js";
11
-
12
- // src/utils/common.ts
13
- var common_exports = {};
14
- __export(common_exports, {
15
- ObjToStr: () => ObjToStr,
16
- StrToObj: () => StrToObj,
17
- getDeviceGuid: () => getDeviceGuid,
18
- getEndOfDay: () => getEndOfDay,
19
- random: () => random,
20
- randomString: () => randomString,
21
- sleep: () => sleep,
22
- timef: () => timef
23
- });
24
- import lodash from "node-karin/lodash";
25
- import moment from "node-karin/moment";
26
- var random = (min, max) => lodash.random(min, max);
27
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
28
- var timef = (format = "YYYY-MM-DD HH:mm:ss") => moment().format(format);
29
- var getDeviceGuid = () => {
30
- function S4() {
31
- return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
32
- }
33
- return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
34
- };
35
- var randomString = (length, type) => {
36
- let str = "0123456789";
37
- if (type === "Lower" || type === "All") {
38
- str += "abcdefghijklmnopqrstuvwxyz";
39
- }
40
- if (type === "Upper" || type === "All") {
41
- str += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
42
- }
43
- return lodash.sampleSize(str, length).join("");
44
- };
45
- var StrToObj = (Str, sep) => {
46
- const strObj = {};
47
- Str.split(sep).forEach((item) => {
48
- const [key, value] = item.split("=");
49
- if (key) {
50
- strObj[key] = value || "";
51
- }
52
- });
53
- return strObj;
54
- };
55
- var ObjToStr = (obj, sep) => {
56
- return Object.entries(obj).filter(([k, v]) => v).map(([k, v]) => `${k}=${v}`).join(sep) + sep;
57
- };
58
- var getEndOfDay = () => Number(moment().endOf("day").format("X")) - Number(moment().format("X"));
59
-
60
- // src/utils/config.ts
61
- import {
62
- copyConfigSync,
63
- logger,
64
- requireFileSync,
65
- watch,
66
- writeJsonSync
67
- } from "node-karin";
68
- import lodash2 from "node-karin/lodash";
69
- var Cfg = new class Cfg2 {
70
- #configCache = null;
71
- constructor() {
72
- copyConfigSync(dir.defConfigDir, dir.ConfigDir, [".json"]);
73
- this.loadConfig();
74
- watch(`${dir.ConfigDir}/config.json`, () => {
75
- logger.info("\u914D\u7F6E\u6587\u4EF6\u5DF2\u4FEE\u6539\uFF0C\u91CD\u65B0\u52A0\u8F7D\u914D\u7F6E");
76
- this.loadConfig();
77
- });
78
- }
79
- loadConfig() {
80
- const cfg = requireFileSync(`${dir.ConfigDir}/config.json`);
81
- const def = requireFileSync(`${dir.defConfigDir}/config.json`);
82
- const mergedConfig = this.mergeWithDefaults(cfg, def);
83
- this.#configCache = mergedConfig;
84
- return mergedConfig;
85
- }
86
- mergeWithDefaults(userConfig, defaultConfig) {
87
- const result = lodash2.merge({}, defaultConfig, userConfig);
88
- if (!lodash2.isEqual(result, userConfig)) {
89
- try {
90
- writeJsonSync(`${dir.ConfigDir}/config.json`, result);
91
- } catch (err) {
92
- logger.error(err);
93
- }
94
- }
95
- return result;
96
- }
97
- get(path, isArray = false) {
98
- const conf = JSON.parse(JSON.stringify(this.#configCache));
99
- const result = lodash2.get(conf, path);
100
- if (isArray) {
101
- if (!Array.isArray(result)) {
102
- logger.error(`\u914D\u7F6E\u8DEF\u5F84 ${path} \u4E0D\u662F\u6570\u7EC4\u7C7B\u578B`);
103
- return new EnhancedArray([], path);
104
- }
105
- return new EnhancedArray(result, path);
106
- }
107
- return result;
108
- }
109
- set(path, value) {
110
- const conf = JSON.parse(JSON.stringify(this.#configCache));
111
- lodash2.set(conf, path, value);
112
- this.#configCache = conf;
113
- try {
114
- writeJsonSync(`${dir.ConfigDir}/config.json`, conf);
115
- } catch (err) {
116
- logger.error(err);
117
- }
118
- }
119
- }();
120
- var EnhancedArray = class extends Array {
121
- #keyPath;
122
- constructor(items, path) {
123
- super(...items);
124
- this.#keyPath = path;
125
- }
126
- add(element) {
127
- this.push(element);
128
- Cfg.set(this.#keyPath, this.slice());
129
- return this;
130
- }
131
- remove(predicate, isIndex = false) {
132
- let newArr = [];
133
- if (isIndex && lodash2.isNumber(predicate)) {
134
- if (predicate < 0 || predicate >= this.length) {
135
- logger.error(`\u7D22\u5F15 ${predicate} \u8D85\u51FA\u8303\u56F4`);
136
- return this;
137
- }
138
- newArr = [...this.slice(0, predicate), ...this.slice(predicate + 1)];
139
- } else if (lodash2.isFunction(predicate)) {
140
- newArr = this.filter((item) => !predicate(item));
141
- } else {
142
- newArr = lodash2.without(this, predicate);
143
- }
144
- this.length = 0;
145
- this.push(...newArr);
146
- Cfg.set(this.#keyPath, this.slice());
147
- return this;
148
- }
149
- };
150
-
151
- // src/core/api/mysApp.ts
152
- var version = { cn: "2.70.1", os: "1.5.0" };
153
- var appId = 2;
154
- var salt = {
155
- os: "6cqshh5dhw73bzxn20oexa9k516chk7s",
156
- "4X": "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
157
- "6X": "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
158
- K2: "S9Hrn38d2b55PamfIR9BNA3Tx9sQTOem",
159
- LK2: "sjdNFJB7XxyDWGIAk0eTV8AOCfMJmyEo",
160
- PROD: "JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS"
161
- };
162
- var MysApp = Object.freeze({
163
- version,
164
- appId,
165
- salt
166
- });
167
-
168
- // src/core/api/define.ts
169
- import md5 from "md5";
170
- import { logger as logger2 } from "node-karin";
171
- import axios, { AxiosHeaders } from "node-karin/axios";
172
- import lodash3 from "node-karin/lodash";
173
- var DefineMysApi = class {
174
- uidInfo;
175
- #apiInfo;
176
- #needDeviceFp = false;
177
- #needCheckCode = false;
178
- constructor(apiInfo, uidInfo, opt = {}) {
179
- this.#apiInfo = apiInfo;
180
- this.uidInfo = uidInfo;
181
- this.#needDeviceFp = !!opt.deviceFp;
182
- this.#needCheckCode = !!opt.checkCode;
183
- }
184
- get isHoyolab() {
185
- return this.uidInfo.type === "hoyolab" /* os */;
186
- }
187
- async getApi(data) {
188
- const { Method, Url, Body, HeaderFn } = this.#apiInfo(this, data);
189
- const Headers = new AxiosHeaders(await HeaderFn({
190
- query: Url.search.substring(1),
191
- body: Body
192
- }, data));
193
- return {
194
- Method,
195
- Url,
196
- Body,
197
- Headers
198
- };
199
- }
200
- async getDevice() {
201
- if (this.Device) return this.Device;
202
- this.Device = {
203
- id: common_exports.getDeviceGuid(),
204
- name: `Karin-${common_exports.randomString(8, "All")}`
205
- };
206
- return this.Device;
207
- }
208
- async request(data, checkCode = true) {
209
- const { Method, Url, Body, HeaderFn } = this.#apiInfo(this, data);
210
- const Headers = new AxiosHeaders(await HeaderFn({
211
- query: Url.search.substring(1),
212
- body: Body
213
- }, data));
214
- if (this.#needDeviceFp) {
215
- Headers.set();
216
- }
217
- const params = {
218
- url: Url.href,
219
- method: Method,
220
- data: Body,
221
- headers: Headers
222
- };
223
- const start = Date.now();
224
- let response;
225
- try {
226
- if (Method === "GET") {
227
- response = await axios.get(params.url, {
228
- headers: params.headers
229
- });
230
- } else if (Method === "POST") {
231
- response = await axios.post(params.url, params.data, {
232
- headers: params.headers
233
- });
234
- } else {
235
- response = axios.request(params);
236
- }
237
- } catch (err) {
238
- logger2.debug(`mys-core-requst[${logger2.green(`${Date.now() - start}ms`)}]: ${JSON.stringify(params, null, 2)}`);
239
- return response;
240
- }
241
- const res = response.data;
242
- logger2.debug(`mys-core-requst[${logger2.green(`${Date.now() - start}ms`)}]: ${JSON.stringify(params, null, 2)} -> ${JSON.stringify(res, null, 2)}`);
243
- if (!res) {
244
- return void 0;
245
- }
246
- if ("retcode" in res) {
247
- res.retcode = Number(res.retcode);
248
- }
249
- if (this.#needCheckCode && checkCode) {
250
- return await this.checkRetCode(res, data);
251
- }
252
- return res;
253
- }
254
- async checkRetCode(res, data, validate = true) {
255
- return res;
256
- }
257
- getDS1(saltKey, query = "", body = "") {
258
- const r = common_exports.randomString(6, "All");
259
- const t = Math.floor(Date.now() / 1e3);
260
- let DS = `salt=${MysApp.salt[saltKey]}&t=${t}&r=${r}`;
261
- if (query || body) DS += `&b=${body}&q=${query}`;
262
- return `${t},${r},${md5(DS)}`;
263
- }
264
- getDS2(saltKey, query = "", body = "") {
265
- const r = lodash3.random(100001, 2e5);
266
- const t = Math.floor(Date.now() / 1e3);
267
- return `${t},${r},${md5(`salt=${MysApp.salt[saltKey]}&t=${t}&r=${r}&b=${body}&q=${query}`)}`;
268
- }
269
- NoHeaders = (options = {}) => ({});
270
- BaseCnHeaders = async () => {
271
- await this.getDevice();
272
- return {
273
- "x-rpc-app_version": MysApp.version.cn,
274
- "x-rpc-client_type": "5",
275
- "x-rpc-device_id": this.Device.id,
276
- "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}`,
277
- Referer: "https://webstatic.mihoyo.com"
278
- };
279
- };
280
- BaseOsHeaders = () => ({
281
- "x-rpc-app_version": MysApp.version.cn,
282
- "x-rpc-client_type": "4",
283
- "x-rpc-language": "zh-cn"
284
- });
285
- PassportHeaders = (options = {}) => ({
286
- "x-rpc-app_version": MysApp.version.cn,
287
- "x-rpc-game_biz": "bbs_cn",
288
- "x-rpc-client_type": "2",
289
- "User-Agent": "okhttp/4.8.0",
290
- "x-rpc-app_id": "bll8iq97cem8",
291
- DS: this.getDS1("PROD", options.query, JSON.stringify(options.body))
292
- });
293
- CookieHeaders = (options = {}) => ({
294
- Cookie: this.uidInfo.cookie,
295
- ...this[this.isHoyolab ? "BaseOsHeaders" : "BaseCnHeaders"]()
296
- });
297
- };
298
-
299
- // src/core/api/mysHosts.ts
300
- var MysHosts = Object.freeze({
301
- bbs: {
302
- ["mihoyo" /* cn */]: "https://bbs-api.miyoushe.com/",
303
- ["hoyolab" /* os */]: "https://bbs-api-os.mihoyo.com/"
304
- },
305
- web: {
306
- ["mihoyo" /* cn */]: "https://api-takumi.mihoyo.com/",
307
- ["hoyolab" /* os */]: "https://api-os-takumi.mihoyo.com/",
308
- /** new web host */
309
- miyoushe: "https://api-takumi.miyoushe.com/"
310
- },
311
- static: "https://api-takumi-static.mihoyo.com/",
312
- record: {
313
- ["mihoyo" /* cn */]: "https://api-takumi-record.mihoyo.com/",
314
- ["hoyolab" /* os */]: "https://bbs-api-os.mihoyo.com/"
315
- },
316
- hk4e: {
317
- ["mihoyo" /* cn */]: "https://hk4e-api.mihoyo.com/",
318
- ["hoyolab" /* os */]: "https://hk4e-api-os.hoyoverse.com/"
319
- },
320
- hk4eGacha: "https://public-operation-hk4e.mihoyo.com/",
321
- hk4eSdk: "https://hk4e-sdk.mihoyo.com/",
322
- napGacha: {
323
- ["mihoyo" /* cn */]: "https://public-operation-nap.mihoyo.com/",
324
- ["hoyolab" /* os */]: "https://public-operation-nap-sg.hoyoverse.com/"
325
- },
326
- publicData: {
327
- ["mihoyo" /* cn */]: "https://public-data-api.mihoyo.com/",
328
- ["hoyolab" /* os */]: "https://sg-public-data-api.hoyoverse.com/"
329
- },
330
- napAct: {
331
- ["mihoyo" /* cn */]: "https://act-nap-api.mihoyo.com/",
332
- ["hoyolab" /* os */]: "https://sg-act-nap-api.mihoyo.com/"
333
- },
334
- passport: "https://passport-api.mihoyo.com/",
335
- hk4eSg: {
336
- ["hoyolab" /* os */]: "https://sg-hk4e-api.hoyolab.com/"
337
- },
338
- publicSg: {
339
- ["hoyolab" /* os */]: "https://sg-public-api.hoyolab.com/",
340
- hoyoverse: "https://sg-public-api.hoyoverse.com/"
341
- }
342
- });
343
-
344
- // src/core/api/mysApis.ts
345
- var fetchQRcode = () => new DefineMysApi(
346
- (self, data) => ({
347
- Method: "POST",
348
- Url: new URL(`${MysHosts.hk4eSdk}hk4e_cn/combo/panda/qrcode/fetch`),
349
- Body: {
350
- app_id: MysApp.appId,
351
- device: data.device
352
- },
353
- HeaderFn: self.NoHeaders
354
- })
355
- );
356
- var queryQRcode = () => new DefineMysApi((self, data) => ({
357
- Method: "POST",
358
- Url: new URL(`${MysHosts.hk4eSdk}hk4e_cn/combo/panda/qrcode/query`),
359
- Body: {
360
- app_id: MysApp.appId,
361
- device: data.device,
362
- ticket: data.ticket
363
- },
364
- HeaderFn: self.NoHeaders
365
- }));
366
- var getTokenByGameToken = () => new DefineMysApi((self, data) => ({
367
- Method: "POST",
368
- Url: new URL(`${MysHosts.passport}account/ma-cn-session/app/getTokenByGameToken`),
369
- Body: {
370
- account_id: data.account_id,
371
- game_token: data.game_token
372
- },
373
- HeaderFn: self.PassportHeaders
374
- }));
375
- var getCookieAccountInfoByGameToken = () => new DefineMysApi((self, data) => ({
376
- Method: "GET",
377
- Url: new URL(`${MysHosts.web["mihoyo" /* cn */]}auth/api/getCookieAccountInfoByGameToken?account_id=${data.account_id}&game_token=${data.game_token}`),
378
- HeaderFn: self.NoHeaders
379
- }));
380
- var getCookieTokenBySToken = (method) => new DefineMysApi((self, data) => ({
381
- Method: method,
382
- Url: function() {
383
- const url = new URL(`${MysHosts.web["mihoyo" /* cn */]}auth/api/getCookieAccountInfoBySToken?game_biz=hk4e_cn&${data.stoken}`);
384
- if (self.isHoyolab) {
385
- url.searchParams.set("game_biz", "hk4e_global");
386
- url.host = MysHosts.web["hoyolab" /* os */].replace(/^https?:\/\//, "");
387
- }
388
- return url;
389
- }(),
390
- HeaderFn: self.NoHeaders
391
- }));
392
- var getUserGameRolesByCookie = (uidInfo) => new DefineMysApi((self, data) => ({
393
- Method: "GET",
394
- Url: new URL(`${MysHosts.web[self.isHoyolab ? "hoyolab" /* os */ : "mihoyo" /* cn */]}binding/api/getUserGameRolesByCookie`),
395
- HeaderFn: self.CookieHeaders
396
- }), uidInfo);
397
- var getUserFullInfo = (uidInfo) => new DefineMysApi((self, data) => ({
398
- Method: "GET",
399
- Url: new URL(`${MysHosts.web.miyoushe}user/wapi/getUserFullInfo?gids=2`),
400
- HeaderFn: self.CookieHeaders
401
- }), uidInfo);
402
-
403
- // src/core/user/userInfo.ts
404
- var BaseUserInfo = class {
405
- userId;
406
- #ltuids = [];
407
- #stuids = [];
408
- #deviceList = [];
409
- #ltuidMap = /* @__PURE__ */ new Map();
410
- constructor(userId) {
411
- this.userId = userId;
412
- }
413
- get ltuids() {
414
- return [...this.#ltuids];
415
- }
416
- get stuids() {
417
- return [...this.#stuids];
418
- }
419
- get deviceList() {
420
- return [...this.#deviceList];
421
- }
422
- async initMysAccountInfo(UserInfo2) {
423
- this.UserInfo = UserInfo2;
424
- const { ltuids, stuids } = UserInfo2;
425
- this.#ltuidMap.clear();
426
- this.#ltuids = ltuids;
427
- this.#stuids = stuids;
428
- const idList = Array.from(/* @__PURE__ */ new Set([...ltuids, ...stuids]));
429
- const MysAccountInfoList = await MysAccountInfoDB.findAllByPks(idList);
430
- MysAccountInfoList.forEach((MysAccountInfo) => {
431
- this.#ltuidMap.set(MysAccountInfo.ltuid, MysAccountInfo);
432
- });
433
- }
434
- getLtuidInfo(ltuid) {
435
- return Object.freeze(this.#ltuidMap.get(ltuid));
436
- }
437
- async saveUserInfo(data) {
438
- await this.UserInfo._save(data);
439
- }
440
- async saveMysAccountInfo(data) {
441
- let MysAccountInfo = this.#ltuidMap.get(data.ltuid);
442
- if (!MysAccountInfo) {
443
- MysAccountInfo = await MysAccountInfoDB.findByPk(data.ltuid, true);
444
- }
445
- await MysAccountInfo._save(data);
446
- this.#ltuidMap.set(data.ltuid, { ...MysAccountInfo, ...data });
447
- }
448
- };
449
- var refreshUidFnMap = /* @__PURE__ */ new Map();
450
- var UserInfo = class extends BaseUserInfo {
451
- static async create(userId) {
452
- const userInfo = new BaseUserInfo(userId);
453
- userInfo.refresh = async () => {
454
- const UserInfoData = await MysUserInfoDB.findByPk(userId, true);
455
- await userInfo.initMysAccountInfo(UserInfoData);
456
- return userInfo;
457
- };
458
- return await userInfo.refresh();
459
- }
460
- static async refreshCookie(stokenParams, serv) {
461
- const res = await getCookieTokenBySToken(
462
- serv === "mihoyo" /* cn */ ? "GET" : "POST"
463
- ).request({
464
- stoken: new URLSearchParams({
465
- stoken: stokenParams.stoken,
466
- mid: stokenParams.mid,
467
- uid: stokenParams.stuid
468
- }).toString()
469
- });
470
- const result = { Serv: serv, cookie: "", message: "" };
471
- if (res?.retcode === -100) {
472
- result.message = "\u767B\u5F55\u72B6\u6001\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0#\u626B\u7801\u767B\u5F55\uFF01";
473
- } else if (res?.data?.cookie_token) {
474
- result.cookie = `ltuid=${stokenParams.stuid};ltoken=${stokenParams.stoken};cookie_token=${res.data.cookie_token};account_id=${stokenParams.stuid}`;
475
- } else {
476
- result.message = "\u83B7\u53D6Cookie\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0#\u626B\u7801\u767B\u5F55\uFF01";
477
- }
478
- return result;
479
- }
480
- static refreshUidFn(key, fn) {
481
- refreshUidFnMap.set(key, fn);
482
- }
483
- static refreshUid = async (options) => {
484
- let message = "";
485
- const uidList = { data: {}, names: {} };
486
- if (refreshUidFnMap.size > 0) {
487
- const res = await getUserGameRolesByCookie(options).request({});
488
- if (res?.retcode === 0) {
489
- refreshUidFnMap.forEach((fnc) => fnc(uidList));
490
- } else if (res?.retcode === -100) {
491
- message = "Cookie\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0#\u626B\u7801\u767B\u5F55\u6216#\u5237\u65B0Cookie\uFF01";
492
- } else {
493
- message = res?.message || "\u5237\u65B0UID\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\uFF01";
494
- }
495
- }
496
- return {
497
- Serv: options.type,
498
- uids: uidList,
499
- message
500
- };
501
- };
502
- };
503
-
504
- export {
505
- common_exports,
506
- Cfg,
507
- MysApp,
508
- DefineMysApi,
509
- fetchQRcode,
510
- queryQRcode,
511
- getTokenByGameToken,
512
- getCookieAccountInfoByGameToken,
513
- getCookieTokenBySToken,
514
- getUserGameRolesByCookie,
515
- getUserFullInfo,
516
- MysHosts,
517
- BaseUserInfo,
518
- UserInfo
519
- };