migu-api-enhanced 1.2.0 → 1.2.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.
package/dist/index.js CHANGED
@@ -8,10 +8,14 @@ var __export = (target, all) => {
8
8
  var modules_exports = {};
9
9
  __export(modules_exports, {
10
10
  checkCanListen: () => checkCanListen,
11
+ checkToken: () => checkToken,
11
12
  getAlbumInfo: () => getAlbumInfo,
12
13
  getAlbumSong: () => getAlbumSong,
13
14
  getComment: () => getComment,
15
+ getMvHls: () => getMvHls,
16
+ getMvInfo: () => getMvInfo,
14
17
  getOpNum: () => getOpNum,
18
+ getPacmToken: () => getPacmToken,
15
19
  getPlaylistInfo: () => getPlaylistInfo,
16
20
  getPlaylistSong: () => getPlaylistSong,
17
21
  getRankIndex: () => getRankIndex,
@@ -26,10 +30,12 @@ __export(modules_exports, {
26
30
  getSingerAlbum: () => getSingerAlbum,
27
31
  getSingerIndex: () => getSingerIndex,
28
32
  getSingerSong: () => getSingerSong,
33
+ getTicketInfo: () => getTicketInfo,
29
34
  getUrlH5V24: () => getUrlH5V24,
30
35
  getUrlV1: () => getUrlV1,
31
36
  getUrlV2: () => getUrlV2,
32
37
  getVersion: () => getVersion,
38
+ loginNP: () => loginNP,
33
39
  searchAlbum: () => searchAlbum,
34
40
  searchConcert: () => searchConcert,
35
41
  searchRbt: () => searchRbt,
@@ -178,8 +184,8 @@ var getRecommendSong = async (size = 20, scene = "TODAY_RECOMMEND") => {
178
184
  };
179
185
 
180
186
  // src/modules/comment.ts
181
- var getComment = async (resourceId, resourceType = 2, hotCommentStart = 0, size = 20) => {
182
- return await h5fetch(`https://app.u.nf.migu.cn/MIGUM3.0/user/comment/stack/v1.0?hotCommentStart=${hotCommentStart}&pageSize=${size}&queryType=1&resourceId=${resourceId}&resourceType=${resourceType}`);
187
+ var getComment = async (resourceId, resourceType = 2, size = 20, hotCommentStart = 0) => {
188
+ 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`);
183
189
  };
184
190
 
185
191
  // src/modules/resourceinfo.ts
@@ -218,8 +224,15 @@ var getUrlV1 = async (contentId, copyrightId, resourceType = "2") => {
218
224
  );
219
225
  };
220
226
 
227
+ // src/utils/deviceID.ts
228
+ function getDeviceId() {
229
+ const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
230
+ const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
231
+ return a.toUpperCase();
232
+ }
233
+
221
234
  // src/modules/url_v2.ts
222
- var getUrlV2 = async (contentId, copyrightId, resourceType = "2") => {
235
+ var getUrlV2 = async (contentId, copyrightId, resourceType = "2", pacmtoken = "") => {
223
236
  const deviceId = getDeviceId();
224
237
  const timestamp = Date.now();
225
238
  const headers = {
@@ -229,7 +242,7 @@ var getUrlV2 = async (contentId, copyrightId, resourceType = "2") => {
229
242
  "subchannel": "014X031",
230
243
  "logId": "cfrom=&appId=h5",
231
244
  "uid": "",
232
- "pacmtoken": "",
245
+ "pacmtoken": pacmtoken,
233
246
  "appId": "h5",
234
247
  "platform": "H5",
235
248
  "deviceId": deviceId,
@@ -256,11 +269,6 @@ var SECURE = "Jk8qzuePiJ1qE3mDYhLQ3T73DtDoAhLP";
256
269
  var aw = 171;
257
270
  var iw = 205;
258
271
  var ow = 1;
259
- function getDeviceId() {
260
- const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
261
- const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
262
- return a.toUpperCase();
263
- }
264
272
  function textEncode(e) {
265
273
  return new TextEncoder().encode(e);
266
274
  }
@@ -371,17 +379,621 @@ var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_mi
371
379
  );
372
380
  };
373
381
 
382
+ // src/modules/mv_info.ts
383
+ var getMvInfo = async (mvIds, {
384
+ needAbsoluteUrl = false
385
+ }) => {
386
+ const res = await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvIds}&resourceType=D&needSimple=01`);
387
+ if (!res) return { error: "\u8BF7\u6C42\u5931\u8D25" };
388
+ if (res.error) return { error: res.error };
389
+ const resource = res.resource || [];
390
+ if (resource.length === 0) return { error: "resource\u4E0D\u5B58\u5728" };
391
+ if (needAbsoluteUrl) {
392
+ resource.forEach((item) => {
393
+ if (!item.rateFormats) return;
394
+ item.rateFormats.forEach((rateFormat) => {
395
+ if (!rateFormat.url) return;
396
+ if (!rateFormat.url.startsWith("http") && !rateFormat.url.startsWith("https")) {
397
+ if (rateFormat.url[0] === "/" && rateFormat.url[1] !== "/") {
398
+ rateFormat.absoluteUrl = `https://freevod.nf.migu.cn${rateFormat.url}`;
399
+ }
400
+ }
401
+ });
402
+ });
403
+ res.resource = resource;
404
+ return res;
405
+ }
406
+ return res;
407
+ };
408
+
409
+ // src/modules/mv_hls.ts
410
+ var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012", needHttps = true) => {
411
+ size = size.toString();
412
+ url = encodeURIComponent(url);
413
+ return await h5fetch(
414
+ `https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/mvplayinfo.do?format=${format}&mvContentId=${mvContentId}&mvCopyrightId=${mvCopyrightId}&needHttps=${needHttps}&size=${size}&url=${url}`,
415
+ {
416
+ method: "GET",
417
+ headers: {
418
+ "Channel": "014021I"
419
+ }
420
+ }
421
+ );
422
+ };
423
+
424
+ // src/utils/rsalib.js
425
+ import crypto from "crypto";
426
+ var rsa;
427
+ globalThis.define = function(id, deps, factory) {
428
+ let req = () => ({});
429
+ let exp = {};
430
+ let mod = { exports: exp };
431
+ factory(req, exp, mod);
432
+ rsa = mod.exports;
433
+ };
434
+ globalThis.window = {};
435
+ Object.defineProperty(globalThis, "navigator", {
436
+ writable: true,
437
+ value: {
438
+ appName: "Netscape",
439
+ appVersion: "5.0 (Node.js)"
440
+ }
441
+ });
442
+ globalThis.window.navigator = globalThis.navigator;
443
+ globalThis.window.crypto = {
444
+ getRandomValues: function(arr) {
445
+ const bytes = crypto.randomBytes(arr.length);
446
+ for (let i = 0; i < arr.length; i++) {
447
+ arr[i] = bytes[i];
448
+ }
449
+ return arr;
450
+ },
451
+ random: function(len) {
452
+ const bytes = crypto.randomBytes(len);
453
+ return Array.from(bytes, (b) => String.fromCharCode(b)).join("");
454
+ }
455
+ };
456
+ define("lib/rsa/rsa", [], function(a, b, c) {
457
+ function d(a2, b2, c2) {
458
+ null != a2 && ("number" == typeof a2 ? this.fromNumber(a2, b2, c2) : null == b2 && "string" != typeof a2 ? this.fromString(a2, 256) : this.fromString(a2, b2));
459
+ }
460
+ function e() {
461
+ return new d(null);
462
+ }
463
+ function f(a2, b2, c2, d2, e2, f2) {
464
+ for (; --f2 >= 0; ) {
465
+ var g2 = b2 * this[a2++] + c2[d2] + e2;
466
+ e2 = Math.floor(g2 / 67108864), c2[d2++] = 67108863 & g2;
467
+ }
468
+ return e2;
469
+ }
470
+ function g(a2, b2, c2, d2, e2, f2) {
471
+ for (var g2 = 32767 & b2, h2 = b2 >> 15; --f2 >= 0; ) {
472
+ var i2 = 32767 & this[a2], j2 = this[a2++] >> 15, k2 = h2 * i2 + j2 * g2;
473
+ i2 = g2 * i2 + ((32767 & k2) << 15) + c2[d2] + (1073741823 & e2), e2 = (i2 >>> 30) + (k2 >>> 15) + h2 * j2 + (e2 >>> 30), c2[d2++] = 1073741823 & i2;
474
+ }
475
+ return e2;
476
+ }
477
+ function h(a2, b2, c2, d2, e2, f2) {
478
+ for (var g2 = 16383 & b2, h2 = b2 >> 14; --f2 >= 0; ) {
479
+ var i2 = 16383 & this[a2], j2 = this[a2++] >> 14, k2 = h2 * i2 + j2 * g2;
480
+ i2 = g2 * i2 + ((16383 & k2) << 14) + c2[d2] + e2, e2 = (i2 >> 28) + (k2 >> 14) + h2 * j2, c2[d2++] = 268435455 & i2;
481
+ }
482
+ return e2;
483
+ }
484
+ function i(a2) {
485
+ return nb.charAt(a2);
486
+ }
487
+ function j(a2, b2) {
488
+ var c2 = ob[a2.charCodeAt(b2)];
489
+ return null == c2 ? -1 : c2;
490
+ }
491
+ function k(a2) {
492
+ for (var b2 = this.t - 1; b2 >= 0; --b2)
493
+ a2[b2] = this[b2];
494
+ a2.t = this.t, a2.s = this.s;
495
+ }
496
+ function l(a2) {
497
+ this.t = 1, this.s = 0 > a2 ? -1 : 0, a2 > 0 ? this[0] = a2 : -1 > a2 ? this[0] = a2 + this.DV : this.t = 0;
498
+ }
499
+ function m(a2) {
500
+ var b2 = e();
501
+ return b2.fromInt(a2), b2;
502
+ }
503
+ function n(a2, b2) {
504
+ var c2;
505
+ if (16 == b2)
506
+ c2 = 4;
507
+ else if (8 == b2)
508
+ c2 = 3;
509
+ else if (256 == b2)
510
+ c2 = 8;
511
+ else if (2 == b2)
512
+ c2 = 1;
513
+ else if (32 == b2)
514
+ c2 = 5;
515
+ else {
516
+ if (4 != b2)
517
+ return void this.fromRadix(a2, b2);
518
+ c2 = 2;
519
+ }
520
+ this.t = 0, this.s = 0;
521
+ for (var e2 = a2.length, f2 = false, g2 = 0; --e2 >= 0; ) {
522
+ var h2 = 8 == c2 ? 255 & a2[e2] : j(a2, e2);
523
+ 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));
524
+ }
525
+ 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);
526
+ }
527
+ function o() {
528
+ for (var a2 = this.s & this.DM; this.t > 0 && this[this.t - 1] == a2; )
529
+ --this.t;
530
+ }
531
+ function p(a2) {
532
+ if (this.s < 0)
533
+ return "-" + this.negate().toString(a2);
534
+ var b2;
535
+ if (16 == a2)
536
+ b2 = 4;
537
+ else if (8 == a2)
538
+ b2 = 3;
539
+ else if (2 == a2)
540
+ b2 = 1;
541
+ else if (32 == a2)
542
+ b2 = 5;
543
+ else {
544
+ if (4 != a2)
545
+ return this.toRadix(a2);
546
+ b2 = 2;
547
+ }
548
+ var c2, d2 = (1 << b2) - 1, e2 = false, f2 = "", g2 = this.t, h2 = this.DB - g2 * this.DB % b2;
549
+ if (g2-- > 0)
550
+ for (h2 < this.DB && (c2 = this[g2] >> h2) > 0 && (e2 = true, f2 = i(c2)); g2 >= 0; )
551
+ 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));
552
+ return e2 ? f2 : "0";
553
+ }
554
+ function q() {
555
+ var a2 = e();
556
+ return d.ZERO.subTo(this, a2), a2;
557
+ }
558
+ function r() {
559
+ return this.s < 0 ? this.negate() : this;
560
+ }
561
+ function s(a2) {
562
+ var b2 = this.s - a2.s;
563
+ if (0 != b2)
564
+ return b2;
565
+ var c2 = this.t;
566
+ if (b2 = c2 - a2.t, 0 != b2)
567
+ return this.s < 0 ? -b2 : b2;
568
+ for (; --c2 >= 0; )
569
+ if (0 != (b2 = this[c2] - a2[c2]))
570
+ return b2;
571
+ return 0;
572
+ }
573
+ function t(a2) {
574
+ var b2, c2 = 1;
575
+ 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;
576
+ }
577
+ function u() {
578
+ return this.t <= 0 ? 0 : this.DB * (this.t - 1) + t(this[this.t - 1] ^ this.s & this.DM);
579
+ }
580
+ function v(a2, b2) {
581
+ var c2;
582
+ for (c2 = this.t - 1; c2 >= 0; --c2)
583
+ b2[c2 + a2] = this[c2];
584
+ for (c2 = a2 - 1; c2 >= 0; --c2)
585
+ b2[c2] = 0;
586
+ b2.t = this.t + a2, b2.s = this.s;
587
+ }
588
+ function w(a2, b2) {
589
+ for (var c2 = a2; c2 < this.t; ++c2)
590
+ b2[c2 - a2] = this[c2];
591
+ b2.t = Math.max(this.t - a2, 0), b2.s = this.s;
592
+ }
593
+ function x(a2, b2) {
594
+ 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;
595
+ for (c2 = this.t - 1; c2 >= 0; --c2)
596
+ b2[c2 + g2 + 1] = this[c2] >> e2 | h2, h2 = (this[c2] & f2) << d2;
597
+ for (c2 = g2 - 1; c2 >= 0; --c2)
598
+ b2[c2] = 0;
599
+ b2[g2] = h2, b2.t = this.t + g2 + 1, b2.s = this.s, b2.clamp();
600
+ }
601
+ function y(a2, b2) {
602
+ b2.s = this.s;
603
+ var c2 = Math.floor(a2 / this.DB);
604
+ if (c2 >= this.t)
605
+ return void (b2.t = 0);
606
+ var d2 = a2 % this.DB, e2 = this.DB - d2, f2 = (1 << d2) - 1;
607
+ b2[0] = this[c2] >> d2;
608
+ for (var g2 = c2 + 1; g2 < this.t; ++g2)
609
+ b2[g2 - c2 - 1] |= (this[g2] & f2) << e2, b2[g2 - c2] = this[g2] >> d2;
610
+ d2 > 0 && (b2[this.t - c2 - 1] |= (this.s & f2) << e2), b2.t = this.t - c2, b2.clamp();
611
+ }
612
+ function z(a2, b2) {
613
+ for (var c2 = 0, d2 = 0, e2 = Math.min(a2.t, this.t); e2 > c2; )
614
+ d2 += this[c2] - a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
615
+ if (a2.t < this.t) {
616
+ for (d2 -= a2.s; c2 < this.t; )
617
+ d2 += this[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
618
+ d2 += this.s;
619
+ } else {
620
+ for (d2 += this.s; c2 < a2.t; )
621
+ d2 -= a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
622
+ d2 -= a2.s;
623
+ }
624
+ b2.s = 0 > d2 ? -1 : 0, -1 > d2 ? b2[c2++] = this.DV + d2 : d2 > 0 && (b2[c2++] = d2), b2.t = c2, b2.clamp();
625
+ }
626
+ function A(a2, b2) {
627
+ var c2 = this.abs(), e2 = a2.abs(), f2 = c2.t;
628
+ for (b2.t = f2 + e2.t; --f2 >= 0; )
629
+ b2[f2] = 0;
630
+ for (f2 = 0; f2 < e2.t; ++f2)
631
+ b2[f2 + c2.t] = c2.am(0, e2[f2], b2, f2, 0, c2.t);
632
+ b2.s = 0, b2.clamp(), this.s != a2.s && d.ZERO.subTo(b2, b2);
633
+ }
634
+ function B(a2) {
635
+ for (var b2 = this.abs(), c2 = a2.t = 2 * b2.t; --c2 >= 0; )
636
+ a2[c2] = 0;
637
+ for (c2 = 0; c2 < b2.t - 1; ++c2) {
638
+ var d2 = b2.am(c2, b2[c2], a2, 2 * c2, 0, 1);
639
+ (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);
640
+ }
641
+ a2.t > 0 && (a2[a2.t - 1] += b2.am(c2, b2[c2], a2, 2 * c2, 0, 1)), a2.s = 0, a2.clamp();
642
+ }
643
+ function C(a2, b2, c2) {
644
+ var f2 = a2.abs();
645
+ if (!(f2.t <= 0)) {
646
+ var g2 = this.abs();
647
+ if (g2.t < f2.t)
648
+ return null != b2 && b2.fromInt(0), void (null != c2 && this.copyTo(c2));
649
+ null == c2 && (c2 = e());
650
+ var h2 = e(), i2 = this.s, j2 = a2.s, k2 = this.DB - t(f2[f2.t - 1]);
651
+ k2 > 0 ? (f2.lShiftTo(k2, h2), g2.lShiftTo(k2, c2)) : (f2.copyTo(h2), g2.copyTo(c2));
652
+ var l2 = h2.t, m2 = h2[l2 - 1];
653
+ if (0 != m2) {
654
+ 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;
655
+ 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; )
656
+ h2[h2.t++] = 0;
657
+ for (; --s2 >= 0; ) {
658
+ var v2 = c2[--r2] == m2 ? this.DM : Math.floor(c2[r2] * o2 + (c2[r2 - 1] + q2) * p2);
659
+ if ((c2[r2] += h2.am(0, v2, c2, s2, 0, l2)) < v2)
660
+ for (h2.dlShiftTo(s2, u2), c2.subTo(u2, c2); c2[r2] < --v2; )
661
+ c2.subTo(u2, c2);
662
+ }
663
+ 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);
664
+ }
665
+ }
666
+ }
667
+ function D(a2) {
668
+ var b2 = e();
669
+ return this.abs().divRemTo(a2, null, b2), this.s < 0 && b2.compareTo(d.ZERO) > 0 && a2.subTo(b2, b2), b2;
670
+ }
671
+ function E(a2) {
672
+ this.m = a2;
673
+ }
674
+ function F(a2) {
675
+ return a2.s < 0 || a2.compareTo(this.m) >= 0 ? a2.mod(this.m) : a2;
676
+ }
677
+ function G(a2) {
678
+ return a2;
679
+ }
680
+ function H(a2) {
681
+ a2.divRemTo(this.m, null, a2);
682
+ }
683
+ function I(a2, b2, c2) {
684
+ a2.multiplyTo(b2, c2), this.reduce(c2);
685
+ }
686
+ function J(a2, b2) {
687
+ a2.squareTo(b2), this.reduce(b2);
688
+ }
689
+ function K() {
690
+ if (this.t < 1)
691
+ return 0;
692
+ var a2 = this[0];
693
+ if (0 == (1 & a2))
694
+ return 0;
695
+ var b2 = 3 & a2;
696
+ 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;
697
+ }
698
+ function L(a2) {
699
+ 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;
700
+ }
701
+ function M(a2) {
702
+ var b2 = e();
703
+ 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;
704
+ }
705
+ function N(a2) {
706
+ var b2 = e();
707
+ return a2.copyTo(b2), this.reduce(b2), b2;
708
+ }
709
+ function O(a2) {
710
+ for (; a2.t <= this.mt2; )
711
+ a2[a2.t++] = 0;
712
+ for (var b2 = 0; b2 < this.m.t; ++b2) {
713
+ var c2 = 32767 & a2[b2], d2 = c2 * this.mpl + ((c2 * this.mph + (a2[b2] >> 15) * this.mpl & this.um) << 15) & a2.DM;
714
+ for (c2 = b2 + this.m.t, a2[c2] += this.m.am(0, d2, a2, b2, 0, this.m.t); a2[c2] >= a2.DV; )
715
+ a2[c2] -= a2.DV, a2[++c2]++;
716
+ }
717
+ a2.clamp(), a2.drShiftTo(this.m.t, a2), a2.compareTo(this.m) >= 0 && a2.subTo(this.m, a2);
718
+ }
719
+ function P(a2, b2) {
720
+ a2.squareTo(b2), this.reduce(b2);
721
+ }
722
+ function Q(a2, b2, c2) {
723
+ a2.multiplyTo(b2, c2), this.reduce(c2);
724
+ }
725
+ function R() {
726
+ return 0 == (this.t > 0 ? 1 & this[0] : this.s);
727
+ }
728
+ function S(a2, b2) {
729
+ if (a2 > 4294967295 || 1 > a2)
730
+ return d.ONE;
731
+ var c2 = e(), f2 = e(), g2 = b2.convert(this), h2 = t(a2) - 1;
732
+ for (g2.copyTo(c2); --h2 >= 0; )
733
+ if (b2.sqrTo(c2, f2), (a2 & 1 << h2) > 0)
734
+ b2.mulTo(f2, g2, c2);
735
+ else {
736
+ var i2 = c2;
737
+ c2 = f2, f2 = i2;
738
+ }
739
+ return b2.revert(c2);
740
+ }
741
+ function T(a2, b2) {
742
+ var c2;
743
+ return c2 = 256 > a2 || b2.isEven() ? new E(b2) : new L(b2), this.exp(a2, c2);
744
+ }
745
+ function U() {
746
+ this.i = 0, this.j = 0, this.S = new Array();
747
+ }
748
+ function V(a2) {
749
+ var b2, c2, d2;
750
+ for (b2 = 0; 256 > b2; ++b2)
751
+ this.S[b2] = b2;
752
+ for (c2 = 0, b2 = 0; 256 > b2; ++b2)
753
+ c2 = c2 + this.S[b2] + a2[b2 % a2.length] & 255, d2 = this.S[b2], this.S[b2] = this.S[c2], this.S[c2] = d2;
754
+ this.i = 0, this.j = 0;
755
+ }
756
+ function W() {
757
+ var a2;
758
+ 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];
759
+ }
760
+ function X() {
761
+ return new U();
762
+ }
763
+ function Y(a2) {
764
+ qb[rb++] ^= 255 & a2, qb[rb++] ^= a2 >> 8 & 255, qb[rb++] ^= a2 >> 16 & 255, qb[rb++] ^= a2 >> 24 & 255, rb >= sb && (rb -= sb);
765
+ }
766
+ function Z() {
767
+ Y((/* @__PURE__ */ new Date()).getTime());
768
+ }
769
+ function $() {
770
+ if (null == pb) {
771
+ for (Z(), pb = X(), pb.init(qb), rb = 0; rb < qb.length; ++rb)
772
+ qb[rb] = 0;
773
+ rb = 0;
774
+ }
775
+ return pb.next();
776
+ }
777
+ function _(a2) {
778
+ var b2;
779
+ for (b2 = 0; b2 < a2.length; ++b2)
780
+ a2[b2] = $();
781
+ }
782
+ function ab() {
783
+ }
784
+ function bb(a2, b2) {
785
+ return new d(a2, b2);
786
+ }
787
+ function cb(a2, b2) {
788
+ if (b2 < a2.length + 11)
789
+ return console.error("Message too long for RSA"), null;
790
+ for (var c2 = new Array(), e2 = a2.length - 1; e2 >= 0 && b2 > 0; ) {
791
+ var f2 = a2.charCodeAt(e2--);
792
+ 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);
793
+ }
794
+ c2[--b2] = 0;
795
+ for (var g2 = new ab(), h2 = new Array(); b2 > 2; ) {
796
+ for (h2[0] = 0; 0 == h2[0]; )
797
+ g2.nextBytes(h2);
798
+ c2[--b2] = h2[0];
799
+ }
800
+ return c2[--b2] = 2, c2[--b2] = 0, new d(c2);
801
+ }
802
+ function db() {
803
+ this.n = null, this.e = 0, this.d = null, this.p = null, this.q = null, this.dmp1 = null, this.dmq1 = null, this.coeff = null;
804
+ }
805
+ function eb(a2, b2) {
806
+ null != a2 && null != b2 && a2.length > 0 && b2.length > 0 ? (this.n = bb(a2, 16), this.e = parseInt(b2, 16)) : console.error("net error");
807
+ }
808
+ function fb(a2) {
809
+ return a2.modPowInt(this.e, this.n);
810
+ }
811
+ function gb(a2) {
812
+ var b2 = cb(a2, this.n.bitLength() + 7 >> 3);
813
+ if (null == b2)
814
+ return null;
815
+ var c2 = this.doPublic(b2);
816
+ if (null == c2)
817
+ return null;
818
+ var d2 = c2.toString(16);
819
+ return 0 == (1 & d2.length) ? d2 : "0" + d2;
820
+ }
821
+ var hb, ib = 244837814094590, jb = 15715070 == (16777215 & ib);
822
+ 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;
823
+ var kb = 52;
824
+ d.prototype.FV = Math.pow(2, kb), d.prototype.F1 = kb - hb, d.prototype.F2 = 2 * hb - kb;
825
+ var lb, mb, nb = "0123456789abcdefghijklmnopqrstuvwxyz", ob = new Array();
826
+ for (lb = "0".charCodeAt(0), mb = 0; 9 >= mb; ++mb)
827
+ ob[lb++] = mb;
828
+ for (lb = "a".charCodeAt(0), mb = 10; 36 > mb; ++mb)
829
+ ob[lb++] = mb;
830
+ for (lb = "A".charCodeAt(0), mb = 10; 36 > mb; ++mb)
831
+ ob[lb++] = mb;
832
+ 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;
833
+ var pb, qb, rb, sb = 256;
834
+ if (null == qb) {
835
+ qb = new Array(), rb = 0;
836
+ var tb;
837
+ if (window.crypto && window.crypto.getRandomValues) {
838
+ var ub = new Uint8Array(32);
839
+ for (window.crypto.getRandomValues(ub), tb = 0; 32 > tb; ++tb)
840
+ qb[rb++] = ub[tb];
841
+ }
842
+ if ("Netscape" == navigator.appName && navigator.appVersion < "5" && window.crypto) {
843
+ var vb = window.crypto.random(32);
844
+ for (tb = 0; tb < vb.length; ++tb)
845
+ qb[rb++] = 255 & vb.charCodeAt(tb);
846
+ }
847
+ for (; sb > rb; )
848
+ tb = Math.floor(65536 * Math.random()), qb[rb++] = tb >>> 8, qb[rb++] = 255 & tb;
849
+ rb = 0, Z();
850
+ }
851
+ ab.prototype.nextBytes = _, db.prototype.doPublic = fb, db.prototype.setPublic = eb, db.prototype.encrypt = gb, c.exports = {
852
+ RSAKey: db
853
+ };
854
+ });
855
+ var rsalib_default = rsa;
856
+
857
+ // src/utils/publicKey.ts
858
+ var getPublicKey = async () => {
859
+ const res = await fetch(
860
+ "https://passport.migu.cn/password/publickey",
861
+ {
862
+ method: "POST"
863
+ }
864
+ );
865
+ if (!res.ok) return;
866
+ const data = await res.json();
867
+ const publicExponent = data.result.publicExponent;
868
+ const modulus = data.result.modulus;
869
+ return { publicExponent, modulus };
870
+ };
871
+
872
+ // src/modules/login_np.ts
873
+ var RSAKey = rsalib_default.RSAKey;
874
+ function randomString() {
875
+ const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
876
+ return random.toLowerCase();
877
+ }
878
+ var loginNP = {
879
+ async authn(username, password) {
880
+ var error = "";
881
+ var $ = {
882
+ "isAsync": true,
883
+ "enpassword": "",
884
+ "captcha": "",
885
+ "appType": "0",
886
+ "loginID": "",
887
+ "relayState": "",
888
+ "sourceID": "220029",
889
+ "imgcodeType": "1",
890
+ "fingerPrint": "",
891
+ "fingerPrintDetail": ""
892
+ };
893
+ const p = await getPublicKey();
894
+ const { publicExponent, modulus } = p || {};
895
+ if (!modulus || !publicExponent) {
896
+ error = "\u83B7\u53D6\u516C\u94A5\u5931\u8D25";
897
+ return { error };
898
+ }
899
+ var rsa2 = new RSAKey();
900
+ rsa2.setPublic(modulus, publicExponent);
901
+ const rsa_pwd = rsa2.encrypt(password);
902
+ const rsa_username = rsa2.encrypt(username);
903
+ const fakeFingerprint = randomString();
904
+ $.fingerPrint = fakeFingerprint;
905
+ $.fingerPrintDetail = fakeFingerprint;
906
+ $.enpassword = rsa_pwd;
907
+ $.loginID = rsa_username;
908
+ const form = new URLSearchParams();
909
+ for (const [key, value] of Object.entries($)) {
910
+ form.append(key, String(value));
911
+ }
912
+ const res = await fetch(
913
+ `https://passport.migu.cn/authn`,
914
+ {
915
+ method: "POST",
916
+ headers: {
917
+ "Host": "passport.migu.cn"
918
+ },
919
+ body: form
920
+ }
921
+ );
922
+ if (!res.ok) return { error: ["\u8BF7\u6C42\u767B\u5F55\u5931\u8D25"] };
923
+ const body = await res.json();
924
+ return body;
925
+ }
926
+ };
927
+
928
+ // src/modules/passport_checkToken.ts
929
+ var checkToken = async (token = "") => {
930
+ return await h5fetch(
931
+ `https://c.musicapp.migu.cn/mgateway/api/checkPacMtoken`,
932
+ {
933
+ headers: {
934
+ "pacmtoken": token
935
+ }
936
+ }
937
+ );
938
+ };
939
+
940
+ // src/modules/passport_pacmToken.ts
941
+ var getPacmToken = async (token = "", type = "2", sourceId = "220029", activityId = "MUSIC-WWW") => {
942
+ const res = await fetch(
943
+ `https://c.musicapp.migu.cn/user/h5/token-validate/v3.0?token=${token}&type=${type}&sourceId=${sourceId}&activityId=${activityId}`,
944
+ {
945
+ headers: {
946
+ "Cookie": "idmpauth=true@passport.migu.cn",
947
+ //?
948
+ "Origin": "https://music.migu.cn",
949
+ "Pragma": "no-cache",
950
+ "Referer": "https://music.migu.cn/"
951
+ },
952
+ method: "GET"
953
+ }
954
+ );
955
+ const headers = res.headers;
956
+ let cookie = [];
957
+ if (typeof headers.getSetCookie === "function") {
958
+ cookie = headers.getSetCookie() || [];
959
+ } else {
960
+ const setCookieHeader = headers.get("set-cookie");
961
+ if (setCookieHeader) {
962
+ cookie = setCookieHeader.split(",").map((c) => c.trim());
963
+ }
964
+ }
965
+ let pacmToken = "";
966
+ cookie.forEach((item) => {
967
+ if (item.includes("pacmtoken=")) {
968
+ pacmToken = item.split(";")[0];
969
+ pacmToken = pacmToken.split("=")[1];
970
+ return;
971
+ }
972
+ });
973
+ const body = await res.json();
974
+ return { pacmToken, cookie, body };
975
+ };
976
+
977
+ // src/modules/ticket.ts
978
+ var getTicketInfo = async (page = 1, pageCount = 20) => {
979
+ return await h5fetch(`https://app.c.nf.migu.cn/MIGUM3.0/v1.0/ticket/home/ticket?pageNum=${page}&pageCount=${pageCount}`);
980
+ };
981
+
374
982
  // src/index.ts
375
983
  function createClient() {
376
984
  return modules_exports;
377
985
  }
378
986
  export {
379
987
  checkCanListen,
988
+ checkToken,
380
989
  createClient,
381
990
  getAlbumInfo,
382
991
  getAlbumSong,
383
992
  getComment,
993
+ getMvHls,
994
+ getMvInfo,
384
995
  getOpNum,
996
+ getPacmToken,
385
997
  getPlaylistInfo,
386
998
  getPlaylistSong,
387
999
  getRankIndex,
@@ -396,10 +1008,12 @@ export {
396
1008
  getSingerAlbum,
397
1009
  getSingerIndex,
398
1010
  getSingerSong,
1011
+ getTicketInfo,
399
1012
  getUrlH5V24,
400
1013
  getUrlV1,
401
1014
  getUrlV2,
402
1015
  getVersion,
1016
+ loginNP,
403
1017
  modules_exports as modules,
404
1018
  searchAlbum,
405
1019
  searchConcert,