migu-api-enhanced 1.2.1 → 1.2.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 +1 -76
- package/dist/index.cjs +776 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -6
- package/dist/index.d.ts +64 -6
- package/dist/index.js +754 -13
- package/dist/index.js.map +1 -1
- package/package.json +62 -62
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,24 +17,37 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var index_exports = {};
|
|
22
32
|
__export(index_exports, {
|
|
23
33
|
checkCanListen: () => checkCanListen,
|
|
34
|
+
checkToken: () => checkToken,
|
|
24
35
|
createClient: () => createClient,
|
|
25
36
|
getAlbumInfo: () => getAlbumInfo,
|
|
26
37
|
getAlbumSong: () => getAlbumSong,
|
|
27
38
|
getComment: () => getComment,
|
|
39
|
+
getMvHls: () => getMvHls,
|
|
40
|
+
getMvInfo: () => getMvInfo,
|
|
28
41
|
getOpNum: () => getOpNum,
|
|
42
|
+
getPacmToken: () => getPacmToken,
|
|
29
43
|
getPlaylistInfo: () => getPlaylistInfo,
|
|
30
44
|
getPlaylistSong: () => getPlaylistSong,
|
|
45
|
+
getRadioRecommend: () => getRadioRecommend,
|
|
31
46
|
getRankIndex: () => getRankIndex,
|
|
32
47
|
getRankInfo: () => getRankInfo,
|
|
33
48
|
getRecommendPlaylist: () => getRecommendPlaylist,
|
|
34
|
-
getRecommendSong: () => getRecommendSong,
|
|
35
49
|
getResourceInfo: () => getResourceInfo,
|
|
50
|
+
getSceneRecommend: () => getSceneRecommend,
|
|
36
51
|
getSearchDefault: () => getSearchDefault,
|
|
37
52
|
getSearchHot: () => getSearchHot,
|
|
38
53
|
getSearchSingerTab: () => getSearchSingerTab,
|
|
@@ -40,11 +55,17 @@ __export(index_exports, {
|
|
|
40
55
|
getSingerAlbum: () => getSingerAlbum,
|
|
41
56
|
getSingerIndex: () => getSingerIndex,
|
|
42
57
|
getSingerSong: () => getSingerSong,
|
|
58
|
+
getTicketInfo: () => getTicketInfo,
|
|
59
|
+
getTodayRecommend: () => getTodayRecommend,
|
|
43
60
|
getUrlH5V24: () => getUrlH5V24,
|
|
44
61
|
getUrlV1: () => getUrlV1,
|
|
45
62
|
getUrlV2: () => getUrlV2,
|
|
63
|
+
getUserBadge: () => getUserBadge,
|
|
64
|
+
getUserHomePage: () => getUserHomePage,
|
|
46
65
|
getVersion: () => getVersion,
|
|
66
|
+
loginNP: () => loginNP,
|
|
47
67
|
modules: () => modules_exports,
|
|
68
|
+
queryUserInfo: () => queryUserInfo,
|
|
48
69
|
searchAlbum: () => searchAlbum,
|
|
49
70
|
searchConcert: () => searchConcert,
|
|
50
71
|
searchRbt: () => searchRbt,
|
|
@@ -60,17 +81,22 @@ module.exports = __toCommonJS(index_exports);
|
|
|
60
81
|
var modules_exports = {};
|
|
61
82
|
__export(modules_exports, {
|
|
62
83
|
checkCanListen: () => checkCanListen,
|
|
84
|
+
checkToken: () => checkToken,
|
|
63
85
|
getAlbumInfo: () => getAlbumInfo,
|
|
64
86
|
getAlbumSong: () => getAlbumSong,
|
|
65
87
|
getComment: () => getComment,
|
|
88
|
+
getMvHls: () => getMvHls,
|
|
89
|
+
getMvInfo: () => getMvInfo,
|
|
66
90
|
getOpNum: () => getOpNum,
|
|
91
|
+
getPacmToken: () => getPacmToken,
|
|
67
92
|
getPlaylistInfo: () => getPlaylistInfo,
|
|
68
93
|
getPlaylistSong: () => getPlaylistSong,
|
|
94
|
+
getRadioRecommend: () => getRadioRecommend,
|
|
69
95
|
getRankIndex: () => getRankIndex,
|
|
70
96
|
getRankInfo: () => getRankInfo,
|
|
71
97
|
getRecommendPlaylist: () => getRecommendPlaylist,
|
|
72
|
-
getRecommendSong: () => getRecommendSong,
|
|
73
98
|
getResourceInfo: () => getResourceInfo,
|
|
99
|
+
getSceneRecommend: () => getSceneRecommend,
|
|
74
100
|
getSearchDefault: () => getSearchDefault,
|
|
75
101
|
getSearchHot: () => getSearchHot,
|
|
76
102
|
getSearchSingerTab: () => getSearchSingerTab,
|
|
@@ -78,10 +104,16 @@ __export(modules_exports, {
|
|
|
78
104
|
getSingerAlbum: () => getSingerAlbum,
|
|
79
105
|
getSingerIndex: () => getSingerIndex,
|
|
80
106
|
getSingerSong: () => getSingerSong,
|
|
107
|
+
getTicketInfo: () => getTicketInfo,
|
|
108
|
+
getTodayRecommend: () => getTodayRecommend,
|
|
81
109
|
getUrlH5V24: () => getUrlH5V24,
|
|
82
110
|
getUrlV1: () => getUrlV1,
|
|
83
111
|
getUrlV2: () => getUrlV2,
|
|
112
|
+
getUserBadge: () => getUserBadge,
|
|
113
|
+
getUserHomePage: () => getUserHomePage,
|
|
84
114
|
getVersion: () => getVersion,
|
|
115
|
+
loginNP: () => loginNP,
|
|
116
|
+
queryUserInfo: () => queryUserInfo,
|
|
85
117
|
searchAlbum: () => searchAlbum,
|
|
86
118
|
searchConcert: () => searchConcert,
|
|
87
119
|
searchRbt: () => searchRbt,
|
|
@@ -224,14 +256,55 @@ var getRecommendPlaylist = async () => {
|
|
|
224
256
|
return await h5fetch(`http://app.c.nf.migu.cn/bmw/index-show/recommend-playlist/v3.0`);
|
|
225
257
|
};
|
|
226
258
|
|
|
259
|
+
// src/utils/deviceID.ts
|
|
260
|
+
function getDeviceId() {
|
|
261
|
+
const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
262
|
+
const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
|
|
263
|
+
return a.toUpperCase();
|
|
264
|
+
}
|
|
265
|
+
|
|
227
266
|
// src/modules/recommend_song.ts
|
|
228
|
-
var
|
|
229
|
-
|
|
267
|
+
var getSceneRecommend = async (scene = "TODAY_RECOMMEND", size = 10) => {
|
|
268
|
+
let params = "";
|
|
269
|
+
if (scene === "PRIVATE_FM") {
|
|
270
|
+
params = "scene=PRIVATE_FM&algorithm=v1&action=1";
|
|
271
|
+
} else if (scene === "TODAY_RECOMMEND") {
|
|
272
|
+
params = `scene=TODAY_RECOMMEND&action=1&size=${size}`;
|
|
273
|
+
} else {
|
|
274
|
+
return { error: "scene\u53C2\u6570\u9519\u8BEF" };
|
|
275
|
+
}
|
|
276
|
+
return await h5fetch(
|
|
277
|
+
`https://app.c.nf.migu.cn/pc/resource-dataloader/recommend-song/v1.0?${params}`,
|
|
278
|
+
{
|
|
279
|
+
headers: {
|
|
280
|
+
"deviceId": getDeviceId()
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// src/modules/recommend_radio.ts
|
|
287
|
+
var getRadioRecommend = async (type = 1) => {
|
|
288
|
+
if (type !== 1 && type !== 2) {
|
|
289
|
+
return { error: "type must be 1 or 2" };
|
|
290
|
+
}
|
|
291
|
+
return await h5fetch(
|
|
292
|
+
`https://app.c.nf.migu.cn/pc/column/music-radio/recommend/song/v2.0?remain=0&actionId=1&type=${type}`,
|
|
293
|
+
{
|
|
294
|
+
method: "GET",
|
|
295
|
+
headers: {
|
|
296
|
+
"Referer": "https://music.migu.cn/",
|
|
297
|
+
"channel": "014X031",
|
|
298
|
+
"deviceId": getDeviceId(),
|
|
299
|
+
"recommendstatus": "1"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
);
|
|
230
303
|
};
|
|
231
304
|
|
|
232
305
|
// src/modules/comment.ts
|
|
233
|
-
var getComment = async (resourceId, resourceType = 2,
|
|
234
|
-
return await h5fetch(`https://
|
|
306
|
+
var getComment = async (resourceId, resourceType = 2, size = 20, hotCommentStart = 0) => {
|
|
307
|
+
return await h5fetch(`https://u.musicapp.migu.cn/MIGUM3.0/user/comment/stack/v1.0?resourceId=${resourceId}&resourceType=${resourceType}&pageSize=${size}&hotCommentStart=${hotCommentStart}&platformType=1&commentId=0&queryType=1`);
|
|
235
308
|
};
|
|
236
309
|
|
|
237
310
|
// src/modules/resourceinfo.ts
|
|
@@ -271,7 +344,7 @@ var getUrlV1 = async (contentId, copyrightId, resourceType = "2") => {
|
|
|
271
344
|
};
|
|
272
345
|
|
|
273
346
|
// src/modules/url_v2.ts
|
|
274
|
-
var getUrlV2 = async (contentId, copyrightId, resourceType = "2") => {
|
|
347
|
+
var getUrlV2 = async (contentId, copyrightId, resourceType = "2", pacmtoken = "") => {
|
|
275
348
|
const deviceId = getDeviceId();
|
|
276
349
|
const timestamp = Date.now();
|
|
277
350
|
const headers = {
|
|
@@ -281,7 +354,7 @@ var getUrlV2 = async (contentId, copyrightId, resourceType = "2") => {
|
|
|
281
354
|
"subchannel": "014X031",
|
|
282
355
|
"logId": "cfrom=&appId=h5",
|
|
283
356
|
"uid": "",
|
|
284
|
-
"pacmtoken":
|
|
357
|
+
"pacmtoken": pacmtoken,
|
|
285
358
|
"appId": "h5",
|
|
286
359
|
"platform": "H5",
|
|
287
360
|
"deviceId": deviceId,
|
|
@@ -308,11 +381,6 @@ var SECURE = "Jk8qzuePiJ1qE3mDYhLQ3T73DtDoAhLP";
|
|
|
308
381
|
var aw = 171;
|
|
309
382
|
var iw = 205;
|
|
310
383
|
var ow = 1;
|
|
311
|
-
function getDeviceId() {
|
|
312
|
-
const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
313
|
-
const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
|
|
314
|
-
return a.toUpperCase();
|
|
315
|
-
}
|
|
316
384
|
function textEncode(e) {
|
|
317
385
|
return new TextEncoder().encode(e);
|
|
318
386
|
}
|
|
@@ -423,6 +491,689 @@ var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_mi
|
|
|
423
491
|
);
|
|
424
492
|
};
|
|
425
493
|
|
|
494
|
+
// src/modules/mv_info.ts
|
|
495
|
+
var getMvInfo = async (mvIds, {
|
|
496
|
+
needAbsoluteUrl = false
|
|
497
|
+
}) => {
|
|
498
|
+
const res = await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvIds}&resourceType=D&needSimple=01`);
|
|
499
|
+
if (!res) return { error: "\u8BF7\u6C42\u5931\u8D25" };
|
|
500
|
+
if (res.error) return { error: res.error };
|
|
501
|
+
const resource = res.resource || [];
|
|
502
|
+
if (resource.length === 0) return { error: "resource\u4E0D\u5B58\u5728" };
|
|
503
|
+
if (needAbsoluteUrl) {
|
|
504
|
+
resource.forEach((item) => {
|
|
505
|
+
if (!item.rateFormats) return;
|
|
506
|
+
item.rateFormats.forEach((rateFormat) => {
|
|
507
|
+
if (!rateFormat.url) return;
|
|
508
|
+
if (!rateFormat.url.startsWith("http") && !rateFormat.url.startsWith("https")) {
|
|
509
|
+
if (rateFormat.url[0] === "/" && rateFormat.url[1] !== "/") {
|
|
510
|
+
rateFormat.absoluteUrl = `https://freevod.nf.migu.cn${rateFormat.url}`;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
});
|
|
515
|
+
res.resource = resource;
|
|
516
|
+
return res;
|
|
517
|
+
}
|
|
518
|
+
return res;
|
|
519
|
+
};
|
|
520
|
+
|
|
521
|
+
// src/modules/mv_hls.ts
|
|
522
|
+
var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012", needHttps = true) => {
|
|
523
|
+
size = size.toString();
|
|
524
|
+
url = encodeURIComponent(url);
|
|
525
|
+
return await h5fetch(
|
|
526
|
+
`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/mvplayinfo.do?format=${format}&mvContentId=${mvContentId}&mvCopyrightId=${mvCopyrightId}&needHttps=${needHttps}&size=${size}&url=${url}`,
|
|
527
|
+
{
|
|
528
|
+
method: "GET",
|
|
529
|
+
headers: {
|
|
530
|
+
"Channel": "014021I"
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
);
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
// src/utils/rsalib.js
|
|
537
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
538
|
+
var rsa;
|
|
539
|
+
globalThis.define = function(id, deps, factory) {
|
|
540
|
+
let req = () => ({});
|
|
541
|
+
let exp = {};
|
|
542
|
+
let mod = { exports: exp };
|
|
543
|
+
factory(req, exp, mod);
|
|
544
|
+
rsa = mod.exports;
|
|
545
|
+
};
|
|
546
|
+
globalThis.window = {};
|
|
547
|
+
Object.defineProperty(globalThis, "navigator", {
|
|
548
|
+
writable: true,
|
|
549
|
+
value: {
|
|
550
|
+
appName: "Netscape",
|
|
551
|
+
appVersion: "5.0 (Node.js)"
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
globalThis.window.navigator = globalThis.navigator;
|
|
555
|
+
globalThis.window.crypto = {
|
|
556
|
+
getRandomValues: function(arr) {
|
|
557
|
+
const bytes = import_crypto.default.randomBytes(arr.length);
|
|
558
|
+
for (let i = 0; i < arr.length; i++) {
|
|
559
|
+
arr[i] = bytes[i];
|
|
560
|
+
}
|
|
561
|
+
return arr;
|
|
562
|
+
},
|
|
563
|
+
random: function(len) {
|
|
564
|
+
const bytes = import_crypto.default.randomBytes(len);
|
|
565
|
+
return Array.from(bytes, (b) => String.fromCharCode(b)).join("");
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
define("lib/rsa/rsa", [], function(a, b, c) {
|
|
569
|
+
function d(a2, b2, c2) {
|
|
570
|
+
null != a2 && ("number" == typeof a2 ? this.fromNumber(a2, b2, c2) : null == b2 && "string" != typeof a2 ? this.fromString(a2, 256) : this.fromString(a2, b2));
|
|
571
|
+
}
|
|
572
|
+
function e() {
|
|
573
|
+
return new d(null);
|
|
574
|
+
}
|
|
575
|
+
function f(a2, b2, c2, d2, e2, f2) {
|
|
576
|
+
for (; --f2 >= 0; ) {
|
|
577
|
+
var g2 = b2 * this[a2++] + c2[d2] + e2;
|
|
578
|
+
e2 = Math.floor(g2 / 67108864), c2[d2++] = 67108863 & g2;
|
|
579
|
+
}
|
|
580
|
+
return e2;
|
|
581
|
+
}
|
|
582
|
+
function g(a2, b2, c2, d2, e2, f2) {
|
|
583
|
+
for (var g2 = 32767 & b2, h2 = b2 >> 15; --f2 >= 0; ) {
|
|
584
|
+
var i2 = 32767 & this[a2], j2 = this[a2++] >> 15, k2 = h2 * i2 + j2 * g2;
|
|
585
|
+
i2 = g2 * i2 + ((32767 & k2) << 15) + c2[d2] + (1073741823 & e2), e2 = (i2 >>> 30) + (k2 >>> 15) + h2 * j2 + (e2 >>> 30), c2[d2++] = 1073741823 & i2;
|
|
586
|
+
}
|
|
587
|
+
return e2;
|
|
588
|
+
}
|
|
589
|
+
function h(a2, b2, c2, d2, e2, f2) {
|
|
590
|
+
for (var g2 = 16383 & b2, h2 = b2 >> 14; --f2 >= 0; ) {
|
|
591
|
+
var i2 = 16383 & this[a2], j2 = this[a2++] >> 14, k2 = h2 * i2 + j2 * g2;
|
|
592
|
+
i2 = g2 * i2 + ((16383 & k2) << 14) + c2[d2] + e2, e2 = (i2 >> 28) + (k2 >> 14) + h2 * j2, c2[d2++] = 268435455 & i2;
|
|
593
|
+
}
|
|
594
|
+
return e2;
|
|
595
|
+
}
|
|
596
|
+
function i(a2) {
|
|
597
|
+
return nb.charAt(a2);
|
|
598
|
+
}
|
|
599
|
+
function j(a2, b2) {
|
|
600
|
+
var c2 = ob[a2.charCodeAt(b2)];
|
|
601
|
+
return null == c2 ? -1 : c2;
|
|
602
|
+
}
|
|
603
|
+
function k(a2) {
|
|
604
|
+
for (var b2 = this.t - 1; b2 >= 0; --b2)
|
|
605
|
+
a2[b2] = this[b2];
|
|
606
|
+
a2.t = this.t, a2.s = this.s;
|
|
607
|
+
}
|
|
608
|
+
function l(a2) {
|
|
609
|
+
this.t = 1, this.s = 0 > a2 ? -1 : 0, a2 > 0 ? this[0] = a2 : -1 > a2 ? this[0] = a2 + this.DV : this.t = 0;
|
|
610
|
+
}
|
|
611
|
+
function m(a2) {
|
|
612
|
+
var b2 = e();
|
|
613
|
+
return b2.fromInt(a2), b2;
|
|
614
|
+
}
|
|
615
|
+
function n(a2, b2) {
|
|
616
|
+
var c2;
|
|
617
|
+
if (16 == b2)
|
|
618
|
+
c2 = 4;
|
|
619
|
+
else if (8 == b2)
|
|
620
|
+
c2 = 3;
|
|
621
|
+
else if (256 == b2)
|
|
622
|
+
c2 = 8;
|
|
623
|
+
else if (2 == b2)
|
|
624
|
+
c2 = 1;
|
|
625
|
+
else if (32 == b2)
|
|
626
|
+
c2 = 5;
|
|
627
|
+
else {
|
|
628
|
+
if (4 != b2)
|
|
629
|
+
return void this.fromRadix(a2, b2);
|
|
630
|
+
c2 = 2;
|
|
631
|
+
}
|
|
632
|
+
this.t = 0, this.s = 0;
|
|
633
|
+
for (var e2 = a2.length, f2 = false, g2 = 0; --e2 >= 0; ) {
|
|
634
|
+
var h2 = 8 == c2 ? 255 & a2[e2] : j(a2, e2);
|
|
635
|
+
0 > h2 ? "-" == a2.charAt(e2) && (f2 = true) : (f2 = false, 0 == g2 ? this[this.t++] = h2 : g2 + c2 > this.DB ? (this[this.t - 1] |= (h2 & (1 << this.DB - g2) - 1) << g2, this[this.t++] = h2 >> this.DB - g2) : this[this.t - 1] |= h2 << g2, g2 += c2, g2 >= this.DB && (g2 -= this.DB));
|
|
636
|
+
}
|
|
637
|
+
8 == c2 && 0 != (128 & a2[0]) && (this.s = -1, g2 > 0 && (this[this.t - 1] |= (1 << this.DB - g2) - 1 << g2)), this.clamp(), f2 && d.ZERO.subTo(this, this);
|
|
638
|
+
}
|
|
639
|
+
function o() {
|
|
640
|
+
for (var a2 = this.s & this.DM; this.t > 0 && this[this.t - 1] == a2; )
|
|
641
|
+
--this.t;
|
|
642
|
+
}
|
|
643
|
+
function p(a2) {
|
|
644
|
+
if (this.s < 0)
|
|
645
|
+
return "-" + this.negate().toString(a2);
|
|
646
|
+
var b2;
|
|
647
|
+
if (16 == a2)
|
|
648
|
+
b2 = 4;
|
|
649
|
+
else if (8 == a2)
|
|
650
|
+
b2 = 3;
|
|
651
|
+
else if (2 == a2)
|
|
652
|
+
b2 = 1;
|
|
653
|
+
else if (32 == a2)
|
|
654
|
+
b2 = 5;
|
|
655
|
+
else {
|
|
656
|
+
if (4 != a2)
|
|
657
|
+
return this.toRadix(a2);
|
|
658
|
+
b2 = 2;
|
|
659
|
+
}
|
|
660
|
+
var c2, d2 = (1 << b2) - 1, e2 = false, f2 = "", g2 = this.t, h2 = this.DB - g2 * this.DB % b2;
|
|
661
|
+
if (g2-- > 0)
|
|
662
|
+
for (h2 < this.DB && (c2 = this[g2] >> h2) > 0 && (e2 = true, f2 = i(c2)); g2 >= 0; )
|
|
663
|
+
b2 > h2 ? (c2 = (this[g2] & (1 << h2) - 1) << b2 - h2, c2 |= this[--g2] >> (h2 += this.DB - b2)) : (c2 = this[g2] >> (h2 -= b2) & d2, 0 >= h2 && (h2 += this.DB, --g2)), c2 > 0 && (e2 = true), e2 && (f2 += i(c2));
|
|
664
|
+
return e2 ? f2 : "0";
|
|
665
|
+
}
|
|
666
|
+
function q() {
|
|
667
|
+
var a2 = e();
|
|
668
|
+
return d.ZERO.subTo(this, a2), a2;
|
|
669
|
+
}
|
|
670
|
+
function r() {
|
|
671
|
+
return this.s < 0 ? this.negate() : this;
|
|
672
|
+
}
|
|
673
|
+
function s(a2) {
|
|
674
|
+
var b2 = this.s - a2.s;
|
|
675
|
+
if (0 != b2)
|
|
676
|
+
return b2;
|
|
677
|
+
var c2 = this.t;
|
|
678
|
+
if (b2 = c2 - a2.t, 0 != b2)
|
|
679
|
+
return this.s < 0 ? -b2 : b2;
|
|
680
|
+
for (; --c2 >= 0; )
|
|
681
|
+
if (0 != (b2 = this[c2] - a2[c2]))
|
|
682
|
+
return b2;
|
|
683
|
+
return 0;
|
|
684
|
+
}
|
|
685
|
+
function t(a2) {
|
|
686
|
+
var b2, c2 = 1;
|
|
687
|
+
return 0 != (b2 = a2 >>> 16) && (a2 = b2, c2 += 16), 0 != (b2 = a2 >> 8) && (a2 = b2, c2 += 8), 0 != (b2 = a2 >> 4) && (a2 = b2, c2 += 4), 0 != (b2 = a2 >> 2) && (a2 = b2, c2 += 2), 0 != (b2 = a2 >> 1) && (a2 = b2, c2 += 1), c2;
|
|
688
|
+
}
|
|
689
|
+
function u() {
|
|
690
|
+
return this.t <= 0 ? 0 : this.DB * (this.t - 1) + t(this[this.t - 1] ^ this.s & this.DM);
|
|
691
|
+
}
|
|
692
|
+
function v(a2, b2) {
|
|
693
|
+
var c2;
|
|
694
|
+
for (c2 = this.t - 1; c2 >= 0; --c2)
|
|
695
|
+
b2[c2 + a2] = this[c2];
|
|
696
|
+
for (c2 = a2 - 1; c2 >= 0; --c2)
|
|
697
|
+
b2[c2] = 0;
|
|
698
|
+
b2.t = this.t + a2, b2.s = this.s;
|
|
699
|
+
}
|
|
700
|
+
function w(a2, b2) {
|
|
701
|
+
for (var c2 = a2; c2 < this.t; ++c2)
|
|
702
|
+
b2[c2 - a2] = this[c2];
|
|
703
|
+
b2.t = Math.max(this.t - a2, 0), b2.s = this.s;
|
|
704
|
+
}
|
|
705
|
+
function x(a2, b2) {
|
|
706
|
+
var c2, d2 = a2 % this.DB, e2 = this.DB - d2, f2 = (1 << e2) - 1, g2 = Math.floor(a2 / this.DB), h2 = this.s << d2 & this.DM;
|
|
707
|
+
for (c2 = this.t - 1; c2 >= 0; --c2)
|
|
708
|
+
b2[c2 + g2 + 1] = this[c2] >> e2 | h2, h2 = (this[c2] & f2) << d2;
|
|
709
|
+
for (c2 = g2 - 1; c2 >= 0; --c2)
|
|
710
|
+
b2[c2] = 0;
|
|
711
|
+
b2[g2] = h2, b2.t = this.t + g2 + 1, b2.s = this.s, b2.clamp();
|
|
712
|
+
}
|
|
713
|
+
function y(a2, b2) {
|
|
714
|
+
b2.s = this.s;
|
|
715
|
+
var c2 = Math.floor(a2 / this.DB);
|
|
716
|
+
if (c2 >= this.t)
|
|
717
|
+
return void (b2.t = 0);
|
|
718
|
+
var d2 = a2 % this.DB, e2 = this.DB - d2, f2 = (1 << d2) - 1;
|
|
719
|
+
b2[0] = this[c2] >> d2;
|
|
720
|
+
for (var g2 = c2 + 1; g2 < this.t; ++g2)
|
|
721
|
+
b2[g2 - c2 - 1] |= (this[g2] & f2) << e2, b2[g2 - c2] = this[g2] >> d2;
|
|
722
|
+
d2 > 0 && (b2[this.t - c2 - 1] |= (this.s & f2) << e2), b2.t = this.t - c2, b2.clamp();
|
|
723
|
+
}
|
|
724
|
+
function z(a2, b2) {
|
|
725
|
+
for (var c2 = 0, d2 = 0, e2 = Math.min(a2.t, this.t); e2 > c2; )
|
|
726
|
+
d2 += this[c2] - a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
|
|
727
|
+
if (a2.t < this.t) {
|
|
728
|
+
for (d2 -= a2.s; c2 < this.t; )
|
|
729
|
+
d2 += this[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
|
|
730
|
+
d2 += this.s;
|
|
731
|
+
} else {
|
|
732
|
+
for (d2 += this.s; c2 < a2.t; )
|
|
733
|
+
d2 -= a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
|
|
734
|
+
d2 -= a2.s;
|
|
735
|
+
}
|
|
736
|
+
b2.s = 0 > d2 ? -1 : 0, -1 > d2 ? b2[c2++] = this.DV + d2 : d2 > 0 && (b2[c2++] = d2), b2.t = c2, b2.clamp();
|
|
737
|
+
}
|
|
738
|
+
function A(a2, b2) {
|
|
739
|
+
var c2 = this.abs(), e2 = a2.abs(), f2 = c2.t;
|
|
740
|
+
for (b2.t = f2 + e2.t; --f2 >= 0; )
|
|
741
|
+
b2[f2] = 0;
|
|
742
|
+
for (f2 = 0; f2 < e2.t; ++f2)
|
|
743
|
+
b2[f2 + c2.t] = c2.am(0, e2[f2], b2, f2, 0, c2.t);
|
|
744
|
+
b2.s = 0, b2.clamp(), this.s != a2.s && d.ZERO.subTo(b2, b2);
|
|
745
|
+
}
|
|
746
|
+
function B(a2) {
|
|
747
|
+
for (var b2 = this.abs(), c2 = a2.t = 2 * b2.t; --c2 >= 0; )
|
|
748
|
+
a2[c2] = 0;
|
|
749
|
+
for (c2 = 0; c2 < b2.t - 1; ++c2) {
|
|
750
|
+
var d2 = b2.am(c2, b2[c2], a2, 2 * c2, 0, 1);
|
|
751
|
+
(a2[c2 + b2.t] += b2.am(c2 + 1, 2 * b2[c2], a2, 2 * c2 + 1, d2, b2.t - c2 - 1)) >= b2.DV && (a2[c2 + b2.t] -= b2.DV, a2[c2 + b2.t + 1] = 1);
|
|
752
|
+
}
|
|
753
|
+
a2.t > 0 && (a2[a2.t - 1] += b2.am(c2, b2[c2], a2, 2 * c2, 0, 1)), a2.s = 0, a2.clamp();
|
|
754
|
+
}
|
|
755
|
+
function C(a2, b2, c2) {
|
|
756
|
+
var f2 = a2.abs();
|
|
757
|
+
if (!(f2.t <= 0)) {
|
|
758
|
+
var g2 = this.abs();
|
|
759
|
+
if (g2.t < f2.t)
|
|
760
|
+
return null != b2 && b2.fromInt(0), void (null != c2 && this.copyTo(c2));
|
|
761
|
+
null == c2 && (c2 = e());
|
|
762
|
+
var h2 = e(), i2 = this.s, j2 = a2.s, k2 = this.DB - t(f2[f2.t - 1]);
|
|
763
|
+
k2 > 0 ? (f2.lShiftTo(k2, h2), g2.lShiftTo(k2, c2)) : (f2.copyTo(h2), g2.copyTo(c2));
|
|
764
|
+
var l2 = h2.t, m2 = h2[l2 - 1];
|
|
765
|
+
if (0 != m2) {
|
|
766
|
+
var n2 = m2 * (1 << this.F1) + (l2 > 1 ? h2[l2 - 2] >> this.F2 : 0), o2 = this.FV / n2, p2 = (1 << this.F1) / n2, q2 = 1 << this.F2, r2 = c2.t, s2 = r2 - l2, u2 = null == b2 ? e() : b2;
|
|
767
|
+
for (h2.dlShiftTo(s2, u2), c2.compareTo(u2) >= 0 && (c2[c2.t++] = 1, c2.subTo(u2, c2)), d.ONE.dlShiftTo(l2, u2), u2.subTo(h2, h2); h2.t < l2; )
|
|
768
|
+
h2[h2.t++] = 0;
|
|
769
|
+
for (; --s2 >= 0; ) {
|
|
770
|
+
var v2 = c2[--r2] == m2 ? this.DM : Math.floor(c2[r2] * o2 + (c2[r2 - 1] + q2) * p2);
|
|
771
|
+
if ((c2[r2] += h2.am(0, v2, c2, s2, 0, l2)) < v2)
|
|
772
|
+
for (h2.dlShiftTo(s2, u2), c2.subTo(u2, c2); c2[r2] < --v2; )
|
|
773
|
+
c2.subTo(u2, c2);
|
|
774
|
+
}
|
|
775
|
+
null != b2 && (c2.drShiftTo(l2, b2), i2 != j2 && d.ZERO.subTo(b2, b2)), c2.t = l2, c2.clamp(), k2 > 0 && c2.rShiftTo(k2, c2), 0 > i2 && d.ZERO.subTo(c2, c2);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
function D(a2) {
|
|
780
|
+
var b2 = e();
|
|
781
|
+
return this.abs().divRemTo(a2, null, b2), this.s < 0 && b2.compareTo(d.ZERO) > 0 && a2.subTo(b2, b2), b2;
|
|
782
|
+
}
|
|
783
|
+
function E(a2) {
|
|
784
|
+
this.m = a2;
|
|
785
|
+
}
|
|
786
|
+
function F(a2) {
|
|
787
|
+
return a2.s < 0 || a2.compareTo(this.m) >= 0 ? a2.mod(this.m) : a2;
|
|
788
|
+
}
|
|
789
|
+
function G(a2) {
|
|
790
|
+
return a2;
|
|
791
|
+
}
|
|
792
|
+
function H(a2) {
|
|
793
|
+
a2.divRemTo(this.m, null, a2);
|
|
794
|
+
}
|
|
795
|
+
function I(a2, b2, c2) {
|
|
796
|
+
a2.multiplyTo(b2, c2), this.reduce(c2);
|
|
797
|
+
}
|
|
798
|
+
function J(a2, b2) {
|
|
799
|
+
a2.squareTo(b2), this.reduce(b2);
|
|
800
|
+
}
|
|
801
|
+
function K() {
|
|
802
|
+
if (this.t < 1)
|
|
803
|
+
return 0;
|
|
804
|
+
var a2 = this[0];
|
|
805
|
+
if (0 == (1 & a2))
|
|
806
|
+
return 0;
|
|
807
|
+
var b2 = 3 & a2;
|
|
808
|
+
return b2 = b2 * (2 - (15 & a2) * b2) & 15, b2 = b2 * (2 - (255 & a2) * b2) & 255, b2 = b2 * (2 - ((65535 & a2) * b2 & 65535)) & 65535, b2 = b2 * (2 - a2 * b2 % this.DV) % this.DV, b2 > 0 ? this.DV - b2 : -b2;
|
|
809
|
+
}
|
|
810
|
+
function L(a2) {
|
|
811
|
+
this.m = a2, this.mp = a2.invDigit(), this.mpl = 32767 & this.mp, this.mph = this.mp >> 15, this.um = (1 << a2.DB - 15) - 1, this.mt2 = 2 * a2.t;
|
|
812
|
+
}
|
|
813
|
+
function M(a2) {
|
|
814
|
+
var b2 = e();
|
|
815
|
+
return a2.abs().dlShiftTo(this.m.t, b2), b2.divRemTo(this.m, null, b2), a2.s < 0 && b2.compareTo(d.ZERO) > 0 && this.m.subTo(b2, b2), b2;
|
|
816
|
+
}
|
|
817
|
+
function N(a2) {
|
|
818
|
+
var b2 = e();
|
|
819
|
+
return a2.copyTo(b2), this.reduce(b2), b2;
|
|
820
|
+
}
|
|
821
|
+
function O(a2) {
|
|
822
|
+
for (; a2.t <= this.mt2; )
|
|
823
|
+
a2[a2.t++] = 0;
|
|
824
|
+
for (var b2 = 0; b2 < this.m.t; ++b2) {
|
|
825
|
+
var c2 = 32767 & a2[b2], d2 = c2 * this.mpl + ((c2 * this.mph + (a2[b2] >> 15) * this.mpl & this.um) << 15) & a2.DM;
|
|
826
|
+
for (c2 = b2 + this.m.t, a2[c2] += this.m.am(0, d2, a2, b2, 0, this.m.t); a2[c2] >= a2.DV; )
|
|
827
|
+
a2[c2] -= a2.DV, a2[++c2]++;
|
|
828
|
+
}
|
|
829
|
+
a2.clamp(), a2.drShiftTo(this.m.t, a2), a2.compareTo(this.m) >= 0 && a2.subTo(this.m, a2);
|
|
830
|
+
}
|
|
831
|
+
function P(a2, b2) {
|
|
832
|
+
a2.squareTo(b2), this.reduce(b2);
|
|
833
|
+
}
|
|
834
|
+
function Q(a2, b2, c2) {
|
|
835
|
+
a2.multiplyTo(b2, c2), this.reduce(c2);
|
|
836
|
+
}
|
|
837
|
+
function R() {
|
|
838
|
+
return 0 == (this.t > 0 ? 1 & this[0] : this.s);
|
|
839
|
+
}
|
|
840
|
+
function S(a2, b2) {
|
|
841
|
+
if (a2 > 4294967295 || 1 > a2)
|
|
842
|
+
return d.ONE;
|
|
843
|
+
var c2 = e(), f2 = e(), g2 = b2.convert(this), h2 = t(a2) - 1;
|
|
844
|
+
for (g2.copyTo(c2); --h2 >= 0; )
|
|
845
|
+
if (b2.sqrTo(c2, f2), (a2 & 1 << h2) > 0)
|
|
846
|
+
b2.mulTo(f2, g2, c2);
|
|
847
|
+
else {
|
|
848
|
+
var i2 = c2;
|
|
849
|
+
c2 = f2, f2 = i2;
|
|
850
|
+
}
|
|
851
|
+
return b2.revert(c2);
|
|
852
|
+
}
|
|
853
|
+
function T(a2, b2) {
|
|
854
|
+
var c2;
|
|
855
|
+
return c2 = 256 > a2 || b2.isEven() ? new E(b2) : new L(b2), this.exp(a2, c2);
|
|
856
|
+
}
|
|
857
|
+
function U() {
|
|
858
|
+
this.i = 0, this.j = 0, this.S = new Array();
|
|
859
|
+
}
|
|
860
|
+
function V(a2) {
|
|
861
|
+
var b2, c2, d2;
|
|
862
|
+
for (b2 = 0; 256 > b2; ++b2)
|
|
863
|
+
this.S[b2] = b2;
|
|
864
|
+
for (c2 = 0, b2 = 0; 256 > b2; ++b2)
|
|
865
|
+
c2 = c2 + this.S[b2] + a2[b2 % a2.length] & 255, d2 = this.S[b2], this.S[b2] = this.S[c2], this.S[c2] = d2;
|
|
866
|
+
this.i = 0, this.j = 0;
|
|
867
|
+
}
|
|
868
|
+
function W() {
|
|
869
|
+
var a2;
|
|
870
|
+
return this.i = this.i + 1 & 255, this.j = this.j + this.S[this.i] & 255, a2 = this.S[this.i], this.S[this.i] = this.S[this.j], this.S[this.j] = a2, this.S[a2 + this.S[this.i] & 255];
|
|
871
|
+
}
|
|
872
|
+
function X() {
|
|
873
|
+
return new U();
|
|
874
|
+
}
|
|
875
|
+
function Y(a2) {
|
|
876
|
+
qb[rb++] ^= 255 & a2, qb[rb++] ^= a2 >> 8 & 255, qb[rb++] ^= a2 >> 16 & 255, qb[rb++] ^= a2 >> 24 & 255, rb >= sb && (rb -= sb);
|
|
877
|
+
}
|
|
878
|
+
function Z() {
|
|
879
|
+
Y((/* @__PURE__ */ new Date()).getTime());
|
|
880
|
+
}
|
|
881
|
+
function $() {
|
|
882
|
+
if (null == pb) {
|
|
883
|
+
for (Z(), pb = X(), pb.init(qb), rb = 0; rb < qb.length; ++rb)
|
|
884
|
+
qb[rb] = 0;
|
|
885
|
+
rb = 0;
|
|
886
|
+
}
|
|
887
|
+
return pb.next();
|
|
888
|
+
}
|
|
889
|
+
function _(a2) {
|
|
890
|
+
var b2;
|
|
891
|
+
for (b2 = 0; b2 < a2.length; ++b2)
|
|
892
|
+
a2[b2] = $();
|
|
893
|
+
}
|
|
894
|
+
function ab() {
|
|
895
|
+
}
|
|
896
|
+
function bb(a2, b2) {
|
|
897
|
+
return new d(a2, b2);
|
|
898
|
+
}
|
|
899
|
+
function cb(a2, b2) {
|
|
900
|
+
if (b2 < a2.length + 11)
|
|
901
|
+
return console.error("Message too long for RSA"), null;
|
|
902
|
+
for (var c2 = new Array(), e2 = a2.length - 1; e2 >= 0 && b2 > 0; ) {
|
|
903
|
+
var f2 = a2.charCodeAt(e2--);
|
|
904
|
+
128 > f2 ? c2[--b2] = f2 : f2 > 127 && 2048 > f2 ? (c2[--b2] = 63 & f2 | 128, c2[--b2] = f2 >> 6 | 192) : (c2[--b2] = 63 & f2 | 128, c2[--b2] = f2 >> 6 & 63 | 128, c2[--b2] = f2 >> 12 | 224);
|
|
905
|
+
}
|
|
906
|
+
c2[--b2] = 0;
|
|
907
|
+
for (var g2 = new ab(), h2 = new Array(); b2 > 2; ) {
|
|
908
|
+
for (h2[0] = 0; 0 == h2[0]; )
|
|
909
|
+
g2.nextBytes(h2);
|
|
910
|
+
c2[--b2] = h2[0];
|
|
911
|
+
}
|
|
912
|
+
return c2[--b2] = 2, c2[--b2] = 0, new d(c2);
|
|
913
|
+
}
|
|
914
|
+
function db() {
|
|
915
|
+
this.n = null, this.e = 0, this.d = null, this.p = null, this.q = null, this.dmp1 = null, this.dmq1 = null, this.coeff = null;
|
|
916
|
+
}
|
|
917
|
+
function eb(a2, b2) {
|
|
918
|
+
null != a2 && null != b2 && a2.length > 0 && b2.length > 0 ? (this.n = bb(a2, 16), this.e = parseInt(b2, 16)) : console.error("net error");
|
|
919
|
+
}
|
|
920
|
+
function fb(a2) {
|
|
921
|
+
return a2.modPowInt(this.e, this.n);
|
|
922
|
+
}
|
|
923
|
+
function gb(a2) {
|
|
924
|
+
var b2 = cb(a2, this.n.bitLength() + 7 >> 3);
|
|
925
|
+
if (null == b2)
|
|
926
|
+
return null;
|
|
927
|
+
var c2 = this.doPublic(b2);
|
|
928
|
+
if (null == c2)
|
|
929
|
+
return null;
|
|
930
|
+
var d2 = c2.toString(16);
|
|
931
|
+
return 0 == (1 & d2.length) ? d2 : "0" + d2;
|
|
932
|
+
}
|
|
933
|
+
var hb, ib = 244837814094590, jb = 15715070 == (16777215 & ib);
|
|
934
|
+
jb && "Microsoft Internet Explorer" == navigator.appName ? (d.prototype.am = g, hb = 30) : jb && "Netscape" != navigator.appName ? (d.prototype.am = f, hb = 26) : (d.prototype.am = h, hb = 28), d.prototype.DB = hb, d.prototype.DM = (1 << hb) - 1, d.prototype.DV = 1 << hb;
|
|
935
|
+
var kb = 52;
|
|
936
|
+
d.prototype.FV = Math.pow(2, kb), d.prototype.F1 = kb - hb, d.prototype.F2 = 2 * hb - kb;
|
|
937
|
+
var lb, mb, nb = "0123456789abcdefghijklmnopqrstuvwxyz", ob = new Array();
|
|
938
|
+
for (lb = "0".charCodeAt(0), mb = 0; 9 >= mb; ++mb)
|
|
939
|
+
ob[lb++] = mb;
|
|
940
|
+
for (lb = "a".charCodeAt(0), mb = 10; 36 > mb; ++mb)
|
|
941
|
+
ob[lb++] = mb;
|
|
942
|
+
for (lb = "A".charCodeAt(0), mb = 10; 36 > mb; ++mb)
|
|
943
|
+
ob[lb++] = mb;
|
|
944
|
+
E.prototype.convert = F, E.prototype.revert = G, E.prototype.reduce = H, E.prototype.mulTo = I, E.prototype.sqrTo = J, L.prototype.convert = M, L.prototype.revert = N, L.prototype.reduce = O, L.prototype.mulTo = Q, L.prototype.sqrTo = P, d.prototype.copyTo = k, d.prototype.fromInt = l, d.prototype.fromString = n, d.prototype.clamp = o, d.prototype.dlShiftTo = v, d.prototype.drShiftTo = w, d.prototype.lShiftTo = x, d.prototype.rShiftTo = y, d.prototype.subTo = z, d.prototype.multiplyTo = A, d.prototype.squareTo = B, d.prototype.divRemTo = C, d.prototype.invDigit = K, d.prototype.isEven = R, d.prototype.exp = S, d.prototype.toString = p, d.prototype.negate = q, d.prototype.abs = r, d.prototype.compareTo = s, d.prototype.bitLength = u, d.prototype.mod = D, d.prototype.modPowInt = T, d.ZERO = m(0), d.ONE = m(1), U.prototype.init = V, U.prototype.next = W;
|
|
945
|
+
var pb, qb, rb, sb = 256;
|
|
946
|
+
if (null == qb) {
|
|
947
|
+
qb = new Array(), rb = 0;
|
|
948
|
+
var tb;
|
|
949
|
+
if (window.crypto && window.crypto.getRandomValues) {
|
|
950
|
+
var ub = new Uint8Array(32);
|
|
951
|
+
for (window.crypto.getRandomValues(ub), tb = 0; 32 > tb; ++tb)
|
|
952
|
+
qb[rb++] = ub[tb];
|
|
953
|
+
}
|
|
954
|
+
if ("Netscape" == navigator.appName && navigator.appVersion < "5" && window.crypto) {
|
|
955
|
+
var vb = window.crypto.random(32);
|
|
956
|
+
for (tb = 0; tb < vb.length; ++tb)
|
|
957
|
+
qb[rb++] = 255 & vb.charCodeAt(tb);
|
|
958
|
+
}
|
|
959
|
+
for (; sb > rb; )
|
|
960
|
+
tb = Math.floor(65536 * Math.random()), qb[rb++] = tb >>> 8, qb[rb++] = 255 & tb;
|
|
961
|
+
rb = 0, Z();
|
|
962
|
+
}
|
|
963
|
+
ab.prototype.nextBytes = _, db.prototype.doPublic = fb, db.prototype.setPublic = eb, db.prototype.encrypt = gb, c.exports = {
|
|
964
|
+
RSAKey: db
|
|
965
|
+
};
|
|
966
|
+
});
|
|
967
|
+
var rsalib_default = rsa;
|
|
968
|
+
|
|
969
|
+
// src/utils/publicKey.ts
|
|
970
|
+
var getPublicKey = async () => {
|
|
971
|
+
const res = await fetch(
|
|
972
|
+
"https://passport.migu.cn/password/publickey",
|
|
973
|
+
{
|
|
974
|
+
method: "POST"
|
|
975
|
+
}
|
|
976
|
+
);
|
|
977
|
+
if (!res.ok) return;
|
|
978
|
+
const data = await res.json();
|
|
979
|
+
const publicExponent = data.result.publicExponent;
|
|
980
|
+
const modulus = data.result.modulus;
|
|
981
|
+
return { publicExponent, modulus };
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
// src/modules/login_np.ts
|
|
985
|
+
var RSAKey = rsalib_default.RSAKey;
|
|
986
|
+
function randomString() {
|
|
987
|
+
const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
|
|
988
|
+
return random.toLowerCase();
|
|
989
|
+
}
|
|
990
|
+
var loginNP = {
|
|
991
|
+
async authn(username, password) {
|
|
992
|
+
var error = "";
|
|
993
|
+
var $ = {
|
|
994
|
+
"isAsync": true,
|
|
995
|
+
"enpassword": "",
|
|
996
|
+
"captcha": "",
|
|
997
|
+
"appType": "0",
|
|
998
|
+
"loginID": "",
|
|
999
|
+
"relayState": "",
|
|
1000
|
+
"sourceID": "220029",
|
|
1001
|
+
"imgcodeType": "1",
|
|
1002
|
+
"fingerPrint": "",
|
|
1003
|
+
"fingerPrintDetail": ""
|
|
1004
|
+
};
|
|
1005
|
+
const p = await getPublicKey();
|
|
1006
|
+
const { publicExponent, modulus } = p || {};
|
|
1007
|
+
if (!modulus || !publicExponent) {
|
|
1008
|
+
error = "\u83B7\u53D6\u516C\u94A5\u5931\u8D25";
|
|
1009
|
+
return { error };
|
|
1010
|
+
}
|
|
1011
|
+
var rsa2 = new RSAKey();
|
|
1012
|
+
rsa2.setPublic(modulus, publicExponent);
|
|
1013
|
+
const rsa_pwd = rsa2.encrypt(password);
|
|
1014
|
+
const rsa_username = rsa2.encrypt(username);
|
|
1015
|
+
const fakeFingerprint = randomString();
|
|
1016
|
+
$.fingerPrint = fakeFingerprint;
|
|
1017
|
+
$.fingerPrintDetail = fakeFingerprint;
|
|
1018
|
+
$.enpassword = rsa_pwd;
|
|
1019
|
+
$.loginID = rsa_username;
|
|
1020
|
+
const form = new URLSearchParams();
|
|
1021
|
+
for (const [key, value] of Object.entries($)) {
|
|
1022
|
+
form.append(key, String(value));
|
|
1023
|
+
}
|
|
1024
|
+
const res = await fetch(
|
|
1025
|
+
`https://passport.migu.cn/authn`,
|
|
1026
|
+
{
|
|
1027
|
+
method: "POST",
|
|
1028
|
+
headers: {
|
|
1029
|
+
"Host": "passport.migu.cn"
|
|
1030
|
+
},
|
|
1031
|
+
body: form
|
|
1032
|
+
}
|
|
1033
|
+
);
|
|
1034
|
+
if (!res.ok) return { error: ["\u8BF7\u6C42\u767B\u5F55\u5931\u8D25"] };
|
|
1035
|
+
const body = await res.json();
|
|
1036
|
+
return body;
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
// src/modules/passport_checkToken.ts
|
|
1041
|
+
var checkToken = async (token = "") => {
|
|
1042
|
+
return await h5fetch(
|
|
1043
|
+
`https://c.musicapp.migu.cn/mgateway/api/checkPacMtoken`,
|
|
1044
|
+
{
|
|
1045
|
+
headers: {
|
|
1046
|
+
"pacmtoken": token
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
);
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
// src/utils/setCookie.ts
|
|
1053
|
+
var parseSetCookies = (headers) => {
|
|
1054
|
+
if (typeof headers.getSetCookie === "function") {
|
|
1055
|
+
return headers.getSetCookie() || [];
|
|
1056
|
+
}
|
|
1057
|
+
const setCookieHeader = headers.get("set-cookie");
|
|
1058
|
+
if (!setCookieHeader) {
|
|
1059
|
+
return [];
|
|
1060
|
+
}
|
|
1061
|
+
return setCookieHeader.split(",").map((c) => c.trim());
|
|
1062
|
+
};
|
|
1063
|
+
var getCookieValue = (cookies, key) => {
|
|
1064
|
+
for (const item of cookies) {
|
|
1065
|
+
const prefix = `${key}=`;
|
|
1066
|
+
if (item.includes(prefix)) {
|
|
1067
|
+
const mainPart = item.split(";")[0];
|
|
1068
|
+
return mainPart.split("=")[1] || "";
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return "";
|
|
1072
|
+
};
|
|
1073
|
+
var getSetCookieValue = (headers, key) => {
|
|
1074
|
+
const cookies = parseSetCookies(headers);
|
|
1075
|
+
return getCookieValue(cookies, key);
|
|
1076
|
+
};
|
|
1077
|
+
|
|
1078
|
+
// src/modules/passport_pacmToken.ts
|
|
1079
|
+
var getPacmToken = async (token = "", type = "2", sourceId = "220029", activityId = "MUSIC-WWW") => {
|
|
1080
|
+
const res = await fetch(
|
|
1081
|
+
`https://c.musicapp.migu.cn/user/h5/token-validate/v3.0?token=${token}&type=${type}&sourceId=${sourceId}&activityId=${activityId}`,
|
|
1082
|
+
{
|
|
1083
|
+
headers: {
|
|
1084
|
+
"Cookie": "idmpauth=true@passport.migu.cn",
|
|
1085
|
+
"Origin": "https://music.migu.cn",
|
|
1086
|
+
"Pragma": "no-cache",
|
|
1087
|
+
"Referer": "https://music.migu.cn/"
|
|
1088
|
+
},
|
|
1089
|
+
method: "GET"
|
|
1090
|
+
}
|
|
1091
|
+
);
|
|
1092
|
+
const cookie = parseSetCookies(res.headers);
|
|
1093
|
+
const pacmToken = getCookieValue(cookie, "pacmtoken");
|
|
1094
|
+
const body = await res.json();
|
|
1095
|
+
return { pacmToken, cookie, body };
|
|
1096
|
+
};
|
|
1097
|
+
|
|
1098
|
+
// src/modules/ticket.ts
|
|
1099
|
+
var getTicketInfo = async (page = 1, pageCount = 20) => {
|
|
1100
|
+
return await h5fetch(`https://app.c.nf.migu.cn/MIGUM3.0/v1.0/ticket/home/ticket?pageNum=${page}&pageCount=${pageCount}`);
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1103
|
+
// src/modules/user_badge.ts
|
|
1104
|
+
var getUserBadge = async (pacmtoken) => {
|
|
1105
|
+
const res = await fetch(
|
|
1106
|
+
`https://app.c.nf.migu.cn/pc/open/api/member/icon/v1.0`,
|
|
1107
|
+
{
|
|
1108
|
+
method: "GET",
|
|
1109
|
+
headers: {
|
|
1110
|
+
"Cookie": `pacmtoken=${pacmtoken}`,
|
|
1111
|
+
"Referer": "https://music.migu.cn/",
|
|
1112
|
+
"channel": "014X031",
|
|
1113
|
+
"timestamp": Date.now().toString()
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
);
|
|
1117
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1118
|
+
const data = await res.json();
|
|
1119
|
+
return { data, pacmtoken: newPacmToken };
|
|
1120
|
+
};
|
|
1121
|
+
|
|
1122
|
+
// src/modules/user_queryInfo.ts
|
|
1123
|
+
var queryUserInfo = async (pacmtoken) => {
|
|
1124
|
+
const res = await fetch(
|
|
1125
|
+
`https://app.c.nf.migu.cn/pc/user/h5/queryUserInfo/v1.0`,
|
|
1126
|
+
{
|
|
1127
|
+
method: "GET",
|
|
1128
|
+
headers: {
|
|
1129
|
+
"Cookie": `pacmtoken=${pacmtoken}`,
|
|
1130
|
+
"channel": "014X031",
|
|
1131
|
+
"Referer": `https://music.migu.cn/`
|
|
1132
|
+
//可不用
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
);
|
|
1136
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1137
|
+
const data = await res.json();
|
|
1138
|
+
return { data, pacmtoken: newPacmToken };
|
|
1139
|
+
};
|
|
1140
|
+
|
|
1141
|
+
// src/modules/user_homePage.ts
|
|
1142
|
+
var getUserHomePage = async (pacmtoken) => {
|
|
1143
|
+
const res = await fetch(
|
|
1144
|
+
`https://app.c.nf.migu.cn/pc/user/home-page/v2.0`,
|
|
1145
|
+
{
|
|
1146
|
+
method: "GET",
|
|
1147
|
+
headers: {
|
|
1148
|
+
"Cookie": `pacmtoken=${pacmtoken}`
|
|
1149
|
+
//"channel": "014X031",
|
|
1150
|
+
//"Referer": `https://music.migu.cn/`
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
);
|
|
1154
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1155
|
+
const data = await res.json();
|
|
1156
|
+
return { data, pacmtoken: newPacmToken };
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
// src/modules/user_recom_today.ts
|
|
1160
|
+
var getTodayRecommend = async (pacmtoken) => {
|
|
1161
|
+
const res = await fetch(
|
|
1162
|
+
`https://app.c.nf.migu.cn/pc/v1.0/template/todayRecommendList/release?actionId=1&index=1&templateVersion=5`,
|
|
1163
|
+
{
|
|
1164
|
+
method: "GET",
|
|
1165
|
+
headers: {
|
|
1166
|
+
"Cookie": `pacmtoken=${pacmtoken}`
|
|
1167
|
+
//"channel": "014X031",
|
|
1168
|
+
//"Referer": `https://music.migu.cn/`
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
);
|
|
1172
|
+
const newPacmToken = getSetCookieValue(res.headers, "pacmtoken");
|
|
1173
|
+
const data = await res.json();
|
|
1174
|
+
return { data, pacmtoken: newPacmToken };
|
|
1175
|
+
};
|
|
1176
|
+
|
|
426
1177
|
// src/index.ts
|
|
427
1178
|
function createClient() {
|
|
428
1179
|
return modules_exports;
|
|
@@ -430,18 +1181,23 @@ function createClient() {
|
|
|
430
1181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
431
1182
|
0 && (module.exports = {
|
|
432
1183
|
checkCanListen,
|
|
1184
|
+
checkToken,
|
|
433
1185
|
createClient,
|
|
434
1186
|
getAlbumInfo,
|
|
435
1187
|
getAlbumSong,
|
|
436
1188
|
getComment,
|
|
1189
|
+
getMvHls,
|
|
1190
|
+
getMvInfo,
|
|
437
1191
|
getOpNum,
|
|
1192
|
+
getPacmToken,
|
|
438
1193
|
getPlaylistInfo,
|
|
439
1194
|
getPlaylistSong,
|
|
1195
|
+
getRadioRecommend,
|
|
440
1196
|
getRankIndex,
|
|
441
1197
|
getRankInfo,
|
|
442
1198
|
getRecommendPlaylist,
|
|
443
|
-
getRecommendSong,
|
|
444
1199
|
getResourceInfo,
|
|
1200
|
+
getSceneRecommend,
|
|
445
1201
|
getSearchDefault,
|
|
446
1202
|
getSearchHot,
|
|
447
1203
|
getSearchSingerTab,
|
|
@@ -449,11 +1205,17 @@ function createClient() {
|
|
|
449
1205
|
getSingerAlbum,
|
|
450
1206
|
getSingerIndex,
|
|
451
1207
|
getSingerSong,
|
|
1208
|
+
getTicketInfo,
|
|
1209
|
+
getTodayRecommend,
|
|
452
1210
|
getUrlH5V24,
|
|
453
1211
|
getUrlV1,
|
|
454
1212
|
getUrlV2,
|
|
1213
|
+
getUserBadge,
|
|
1214
|
+
getUserHomePage,
|
|
455
1215
|
getVersion,
|
|
1216
|
+
loginNP,
|
|
456
1217
|
modules,
|
|
1218
|
+
queryUserInfo,
|
|
457
1219
|
searchAlbum,
|
|
458
1220
|
searchConcert,
|
|
459
1221
|
searchRbt,
|