migu-api-enhanced 1.2.5 → 2.0.1

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.cjs CHANGED
@@ -30,6 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ MiguUtils: () => utils_exports,
34
+ RSAKey: () => RSAKey,
35
+ URLParams: () => URLParams,
33
36
  YDRZ: () => YDRZ,
34
37
  checkCanListen: () => checkCanListen,
35
38
  checkToken: () => checkToken,
@@ -37,12 +40,15 @@ __export(index_exports, {
37
40
  getAlbumInfo: () => getAlbumInfo,
38
41
  getAlbumSong: () => getAlbumSong,
39
42
  getComment: () => getComment,
43
+ getDeviceId: () => getDeviceId,
44
+ getMVRecommend: () => getMVRecommend,
40
45
  getMvHls: () => getMvHls,
41
46
  getMvInfo: () => getMvInfo,
42
47
  getOpNum: () => getOpNum,
43
48
  getPacmToken: () => getPacmToken,
44
49
  getPlaylistInfo: () => getPlaylistInfo,
45
50
  getPlaylistSong: () => getPlaylistSong,
51
+ getPublicKey: () => getPublicKey,
46
52
  getRadioRecommend: () => getRadioRecommend,
47
53
  getRankIndex: () => getRankIndex,
48
54
  getRankInfo: () => getRankInfo,
@@ -70,9 +76,11 @@ __export(index_exports, {
70
76
  getVersion: () => getVersion,
71
77
  loginNP: () => loginNP,
72
78
  loginOneClick: () => loginOneClick,
79
+ loginPhone: () => loginPhone,
73
80
  loginSim: () => loginSim,
74
81
  modules: () => modules_exports,
75
82
  queryUserInfo: () => queryUserInfo,
83
+ randomUA: () => randomUA,
76
84
  searchAlbum: () => searchAlbum,
77
85
  searchConcert: () => searchConcert,
78
86
  searchRbt: () => searchRbt,
@@ -80,7 +88,8 @@ __export(index_exports, {
80
88
  searchSong: () => searchSong,
81
89
  searchSuggest: () => searchSuggest,
82
90
  searchTicket: () => searchTicket,
83
- searchVideo: () => searchVideo
91
+ searchVideo: () => searchVideo,
92
+ ua: () => ua
84
93
  });
85
94
  module.exports = __toCommonJS(index_exports);
86
95
 
@@ -93,6 +102,7 @@ __export(modules_exports, {
93
102
  getAlbumInfo: () => getAlbumInfo,
94
103
  getAlbumSong: () => getAlbumSong,
95
104
  getComment: () => getComment,
105
+ getMVRecommend: () => getMVRecommend,
96
106
  getMvHls: () => getMvHls,
97
107
  getMvInfo: () => getMvInfo,
98
108
  getOpNum: () => getOpNum,
@@ -126,6 +136,7 @@ __export(modules_exports, {
126
136
  getVersion: () => getVersion,
127
137
  loginNP: () => loginNP,
128
138
  loginOneClick: () => loginOneClick,
139
+ loginPhone: () => loginPhone,
129
140
  loginSim: () => loginSim,
130
141
  queryUserInfo: () => queryUserInfo,
131
142
  searchAlbum: () => searchAlbum,
@@ -503,13 +514,13 @@ var decryptData2 = async (blob) => {
503
514
  };
504
515
 
505
516
  // src/modules/version.ts
506
- var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_migu") => {
517
+ var getVersion = async (channel = "0146921", version = "8.4.0", ua2 = "Android_migu") => {
507
518
  return await h5fetch(
508
519
  `http://app.c.nf.migu.cn/MIGUM2.0/resource/client/version/v1.0`,
509
520
  {
510
521
  headers: {
511
522
  "channel": channel,
512
- "ua": ua,
523
+ "ua": ua2,
513
524
  "version": version
514
525
  }
515
526
  }
@@ -517,8 +528,8 @@ var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_mi
517
528
  };
518
529
 
519
530
  // src/modules/mv_info.ts
520
- var getMvInfo = async (mvIds) => {
521
- return h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvIds}&resourceType=D&needSimple=01`);
531
+ var getMvInfo = async (mvContentId) => {
532
+ return await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvContentId}&resourceType=D&needSimple=01`);
522
533
  };
523
534
 
524
535
  // src/modules/mv_hls.ts
@@ -535,438 +546,51 @@ var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012",
535
546
  );
536
547
  };
537
548
 
538
- // src/utils/rsalib.js
549
+ // src/utils/rsalib.ts
539
550
  var import_crypto = __toESM(require("crypto"), 1);
540
- var rsa;
541
- globalThis.define = function(id, deps, factory) {
542
- let req = () => ({});
543
- let exp = {};
544
- let mod = { exports: exp };
545
- factory(req, exp, mod);
546
- rsa = mod.exports;
547
- };
548
- globalThis.window = {};
549
- Object.defineProperty(globalThis, "navigator", {
550
- writable: true,
551
- value: {
552
- appName: "Netscape",
553
- appVersion: "5.0 (Node.js)"
554
- }
555
- });
556
- globalThis.window.navigator = globalThis.navigator;
557
- globalThis.window.crypto = {
558
- getRandomValues: function(arr) {
559
- const bytes = import_crypto.default.randomBytes(arr.length);
560
- for (let i = 0; i < arr.length; i++) {
561
- arr[i] = bytes[i];
562
- }
563
- return arr;
564
- },
565
- random: function(len) {
566
- const bytes = import_crypto.default.randomBytes(len);
567
- return Array.from(bytes, (b) => String.fromCharCode(b)).join("");
568
- }
569
- };
570
- define("lib/rsa/rsa", [], function(a, b, c) {
571
- function d(a2, b2, c2) {
572
- null != a2 && ("number" == typeof a2 ? this.fromNumber(a2, b2, c2) : null == b2 && "string" != typeof a2 ? this.fromString(a2, 256) : this.fromString(a2, b2));
573
- }
574
- function e() {
575
- return new d(null);
576
- }
577
- function f(a2, b2, c2, d2, e2, f2) {
578
- for (; --f2 >= 0; ) {
579
- var g2 = b2 * this[a2++] + c2[d2] + e2;
580
- e2 = Math.floor(g2 / 67108864), c2[d2++] = 67108863 & g2;
581
- }
582
- return e2;
583
- }
584
- function g(a2, b2, c2, d2, e2, f2) {
585
- for (var g2 = 32767 & b2, h2 = b2 >> 15; --f2 >= 0; ) {
586
- var i2 = 32767 & this[a2], j2 = this[a2++] >> 15, k2 = h2 * i2 + j2 * g2;
587
- i2 = g2 * i2 + ((32767 & k2) << 15) + c2[d2] + (1073741823 & e2), e2 = (i2 >>> 30) + (k2 >>> 15) + h2 * j2 + (e2 >>> 30), c2[d2++] = 1073741823 & i2;
588
- }
589
- return e2;
590
- }
591
- function h(a2, b2, c2, d2, e2, f2) {
592
- for (var g2 = 16383 & b2, h2 = b2 >> 14; --f2 >= 0; ) {
593
- var i2 = 16383 & this[a2], j2 = this[a2++] >> 14, k2 = h2 * i2 + j2 * g2;
594
- i2 = g2 * i2 + ((16383 & k2) << 14) + c2[d2] + e2, e2 = (i2 >> 28) + (k2 >> 14) + h2 * j2, c2[d2++] = 268435455 & i2;
595
- }
596
- return e2;
597
- }
598
- function i(a2) {
599
- return nb.charAt(a2);
600
- }
601
- function j(a2, b2) {
602
- var c2 = ob[a2.charCodeAt(b2)];
603
- return null == c2 ? -1 : c2;
604
- }
605
- function k(a2) {
606
- for (var b2 = this.t - 1; b2 >= 0; --b2)
607
- a2[b2] = this[b2];
608
- a2.t = this.t, a2.s = this.s;
609
- }
610
- function l(a2) {
611
- this.t = 1, this.s = 0 > a2 ? -1 : 0, a2 > 0 ? this[0] = a2 : -1 > a2 ? this[0] = a2 + this.DV : this.t = 0;
612
- }
613
- function m(a2) {
614
- var b2 = e();
615
- return b2.fromInt(a2), b2;
616
- }
617
- function n(a2, b2) {
618
- var c2;
619
- if (16 == b2)
620
- c2 = 4;
621
- else if (8 == b2)
622
- c2 = 3;
623
- else if (256 == b2)
624
- c2 = 8;
625
- else if (2 == b2)
626
- c2 = 1;
627
- else if (32 == b2)
628
- c2 = 5;
629
- else {
630
- if (4 != b2)
631
- return void this.fromRadix(a2, b2);
632
- c2 = 2;
633
- }
634
- this.t = 0, this.s = 0;
635
- for (var e2 = a2.length, f2 = false, g2 = 0; --e2 >= 0; ) {
636
- var h2 = 8 == c2 ? 255 & a2[e2] : j(a2, e2);
637
- 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));
638
- }
639
- 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);
640
- }
641
- function o() {
642
- for (var a2 = this.s & this.DM; this.t > 0 && this[this.t - 1] == a2; )
643
- --this.t;
644
- }
645
- function p(a2) {
646
- if (this.s < 0)
647
- return "-" + this.negate().toString(a2);
648
- var b2;
649
- if (16 == a2)
650
- b2 = 4;
651
- else if (8 == a2)
652
- b2 = 3;
653
- else if (2 == a2)
654
- b2 = 1;
655
- else if (32 == a2)
656
- b2 = 5;
657
- else {
658
- if (4 != a2)
659
- return this.toRadix(a2);
660
- b2 = 2;
661
- }
662
- var c2, d2 = (1 << b2) - 1, e2 = false, f2 = "", g2 = this.t, h2 = this.DB - g2 * this.DB % b2;
663
- if (g2-- > 0)
664
- for (h2 < this.DB && (c2 = this[g2] >> h2) > 0 && (e2 = true, f2 = i(c2)); g2 >= 0; )
665
- 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));
666
- return e2 ? f2 : "0";
667
- }
668
- function q() {
669
- var a2 = e();
670
- return d.ZERO.subTo(this, a2), a2;
671
- }
672
- function r() {
673
- return this.s < 0 ? this.negate() : this;
674
- }
675
- function s(a2) {
676
- var b2 = this.s - a2.s;
677
- if (0 != b2)
678
- return b2;
679
- var c2 = this.t;
680
- if (b2 = c2 - a2.t, 0 != b2)
681
- return this.s < 0 ? -b2 : b2;
682
- for (; --c2 >= 0; )
683
- if (0 != (b2 = this[c2] - a2[c2]))
684
- return b2;
685
- return 0;
686
- }
687
- function t(a2) {
688
- var b2, c2 = 1;
689
- 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;
690
- }
691
- function u() {
692
- return this.t <= 0 ? 0 : this.DB * (this.t - 1) + t(this[this.t - 1] ^ this.s & this.DM);
693
- }
694
- function v(a2, b2) {
695
- var c2;
696
- for (c2 = this.t - 1; c2 >= 0; --c2)
697
- b2[c2 + a2] = this[c2];
698
- for (c2 = a2 - 1; c2 >= 0; --c2)
699
- b2[c2] = 0;
700
- b2.t = this.t + a2, b2.s = this.s;
701
- }
702
- function w(a2, b2) {
703
- for (var c2 = a2; c2 < this.t; ++c2)
704
- b2[c2 - a2] = this[c2];
705
- b2.t = Math.max(this.t - a2, 0), b2.s = this.s;
706
- }
707
- function x(a2, b2) {
708
- 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;
709
- for (c2 = this.t - 1; c2 >= 0; --c2)
710
- b2[c2 + g2 + 1] = this[c2] >> e2 | h2, h2 = (this[c2] & f2) << d2;
711
- for (c2 = g2 - 1; c2 >= 0; --c2)
712
- b2[c2] = 0;
713
- b2[g2] = h2, b2.t = this.t + g2 + 1, b2.s = this.s, b2.clamp();
714
- }
715
- function y(a2, b2) {
716
- b2.s = this.s;
717
- var c2 = Math.floor(a2 / this.DB);
718
- if (c2 >= this.t)
719
- return void (b2.t = 0);
720
- var d2 = a2 % this.DB, e2 = this.DB - d2, f2 = (1 << d2) - 1;
721
- b2[0] = this[c2] >> d2;
722
- for (var g2 = c2 + 1; g2 < this.t; ++g2)
723
- b2[g2 - c2 - 1] |= (this[g2] & f2) << e2, b2[g2 - c2] = this[g2] >> d2;
724
- d2 > 0 && (b2[this.t - c2 - 1] |= (this.s & f2) << e2), b2.t = this.t - c2, b2.clamp();
725
- }
726
- function z(a2, b2) {
727
- for (var c2 = 0, d2 = 0, e2 = Math.min(a2.t, this.t); e2 > c2; )
728
- d2 += this[c2] - a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
729
- if (a2.t < this.t) {
730
- for (d2 -= a2.s; c2 < this.t; )
731
- d2 += this[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
732
- d2 += this.s;
733
- } else {
734
- for (d2 += this.s; c2 < a2.t; )
735
- d2 -= a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
736
- d2 -= a2.s;
737
- }
738
- b2.s = 0 > d2 ? -1 : 0, -1 > d2 ? b2[c2++] = this.DV + d2 : d2 > 0 && (b2[c2++] = d2), b2.t = c2, b2.clamp();
739
- }
740
- function A(a2, b2) {
741
- var c2 = this.abs(), e2 = a2.abs(), f2 = c2.t;
742
- for (b2.t = f2 + e2.t; --f2 >= 0; )
743
- b2[f2] = 0;
744
- for (f2 = 0; f2 < e2.t; ++f2)
745
- b2[f2 + c2.t] = c2.am(0, e2[f2], b2, f2, 0, c2.t);
746
- b2.s = 0, b2.clamp(), this.s != a2.s && d.ZERO.subTo(b2, b2);
747
- }
748
- function B(a2) {
749
- for (var b2 = this.abs(), c2 = a2.t = 2 * b2.t; --c2 >= 0; )
750
- a2[c2] = 0;
751
- for (c2 = 0; c2 < b2.t - 1; ++c2) {
752
- var d2 = b2.am(c2, b2[c2], a2, 2 * c2, 0, 1);
753
- (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);
754
- }
755
- a2.t > 0 && (a2[a2.t - 1] += b2.am(c2, b2[c2], a2, 2 * c2, 0, 1)), a2.s = 0, a2.clamp();
756
- }
757
- function C(a2, b2, c2) {
758
- var f2 = a2.abs();
759
- if (!(f2.t <= 0)) {
760
- var g2 = this.abs();
761
- if (g2.t < f2.t)
762
- return null != b2 && b2.fromInt(0), void (null != c2 && this.copyTo(c2));
763
- null == c2 && (c2 = e());
764
- var h2 = e(), i2 = this.s, j2 = a2.s, k2 = this.DB - t(f2[f2.t - 1]);
765
- k2 > 0 ? (f2.lShiftTo(k2, h2), g2.lShiftTo(k2, c2)) : (f2.copyTo(h2), g2.copyTo(c2));
766
- var l2 = h2.t, m2 = h2[l2 - 1];
767
- if (0 != m2) {
768
- 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;
769
- 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; )
770
- h2[h2.t++] = 0;
771
- for (; --s2 >= 0; ) {
772
- var v2 = c2[--r2] == m2 ? this.DM : Math.floor(c2[r2] * o2 + (c2[r2 - 1] + q2) * p2);
773
- if ((c2[r2] += h2.am(0, v2, c2, s2, 0, l2)) < v2)
774
- for (h2.dlShiftTo(s2, u2), c2.subTo(u2, c2); c2[r2] < --v2; )
775
- c2.subTo(u2, c2);
776
- }
777
- 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);
778
- }
779
- }
780
- }
781
- function D(a2) {
782
- var b2 = e();
783
- return this.abs().divRemTo(a2, null, b2), this.s < 0 && b2.compareTo(d.ZERO) > 0 && a2.subTo(b2, b2), b2;
784
- }
785
- function E(a2) {
786
- this.m = a2;
787
- }
788
- function F(a2) {
789
- return a2.s < 0 || a2.compareTo(this.m) >= 0 ? a2.mod(this.m) : a2;
790
- }
791
- function G(a2) {
792
- return a2;
793
- }
794
- function H(a2) {
795
- a2.divRemTo(this.m, null, a2);
796
- }
797
- function I(a2, b2, c2) {
798
- a2.multiplyTo(b2, c2), this.reduce(c2);
799
- }
800
- function J(a2, b2) {
801
- a2.squareTo(b2), this.reduce(b2);
802
- }
803
- function K() {
804
- if (this.t < 1)
805
- return 0;
806
- var a2 = this[0];
807
- if (0 == (1 & a2))
808
- return 0;
809
- var b2 = 3 & a2;
810
- 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;
811
- }
812
- function L(a2) {
813
- 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;
814
- }
815
- function M(a2) {
816
- var b2 = e();
817
- 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;
818
- }
819
- function N(a2) {
820
- var b2 = e();
821
- return a2.copyTo(b2), this.reduce(b2), b2;
822
- }
823
- function O(a2) {
824
- for (; a2.t <= this.mt2; )
825
- a2[a2.t++] = 0;
826
- for (var b2 = 0; b2 < this.m.t; ++b2) {
827
- var c2 = 32767 & a2[b2], d2 = c2 * this.mpl + ((c2 * this.mph + (a2[b2] >> 15) * this.mpl & this.um) << 15) & a2.DM;
828
- for (c2 = b2 + this.m.t, a2[c2] += this.m.am(0, d2, a2, b2, 0, this.m.t); a2[c2] >= a2.DV; )
829
- a2[c2] -= a2.DV, a2[++c2]++;
830
- }
831
- a2.clamp(), a2.drShiftTo(this.m.t, a2), a2.compareTo(this.m) >= 0 && a2.subTo(this.m, a2);
832
- }
833
- function P(a2, b2) {
834
- a2.squareTo(b2), this.reduce(b2);
835
- }
836
- function Q(a2, b2, c2) {
837
- a2.multiplyTo(b2, c2), this.reduce(c2);
838
- }
839
- function R() {
840
- return 0 == (this.t > 0 ? 1 & this[0] : this.s);
841
- }
842
- function S(a2, b2) {
843
- if (a2 > 4294967295 || 1 > a2)
844
- return d.ONE;
845
- var c2 = e(), f2 = e(), g2 = b2.convert(this), h2 = t(a2) - 1;
846
- for (g2.copyTo(c2); --h2 >= 0; )
847
- if (b2.sqrTo(c2, f2), (a2 & 1 << h2) > 0)
848
- b2.mulTo(f2, g2, c2);
849
- else {
850
- var i2 = c2;
851
- c2 = f2, f2 = i2;
852
- }
853
- return b2.revert(c2);
854
- }
855
- function T(a2, b2) {
856
- var c2;
857
- return c2 = 256 > a2 || b2.isEven() ? new E(b2) : new L(b2), this.exp(a2, c2);
858
- }
859
- function U() {
860
- this.i = 0, this.j = 0, this.S = new Array();
861
- }
862
- function V(a2) {
863
- var b2, c2, d2;
864
- for (b2 = 0; 256 > b2; ++b2)
865
- this.S[b2] = b2;
866
- for (c2 = 0, b2 = 0; 256 > b2; ++b2)
867
- c2 = c2 + this.S[b2] + a2[b2 % a2.length] & 255, d2 = this.S[b2], this.S[b2] = this.S[c2], this.S[c2] = d2;
868
- this.i = 0, this.j = 0;
869
- }
870
- function W() {
871
- var a2;
872
- 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];
873
- }
874
- function X() {
875
- return new U();
876
- }
877
- function Y(a2) {
878
- qb[rb++] ^= 255 & a2, qb[rb++] ^= a2 >> 8 & 255, qb[rb++] ^= a2 >> 16 & 255, qb[rb++] ^= a2 >> 24 & 255, rb >= sb && (rb -= sb);
879
- }
880
- function Z() {
881
- Y((/* @__PURE__ */ new Date()).getTime());
882
- }
883
- function $() {
884
- if (null == pb) {
885
- for (Z(), pb = X(), pb.init(qb), rb = 0; rb < qb.length; ++rb)
886
- qb[rb] = 0;
887
- rb = 0;
888
- }
889
- return pb.next();
890
- }
891
- function _(a2) {
892
- var b2;
893
- for (b2 = 0; b2 < a2.length; ++b2)
894
- a2[b2] = $();
895
- }
896
- function ab() {
897
- }
898
- function bb(a2, b2) {
899
- return new d(a2, b2);
900
- }
901
- function cb(a2, b2) {
902
- if (b2 < a2.length + 11)
903
- return console.error("Message too long for RSA"), null;
904
- for (var c2 = new Array(), e2 = a2.length - 1; e2 >= 0 && b2 > 0; ) {
905
- var f2 = a2.charCodeAt(e2--);
906
- 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);
907
- }
908
- c2[--b2] = 0;
909
- for (var g2 = new ab(), h2 = new Array(); b2 > 2; ) {
910
- for (h2[0] = 0; 0 == h2[0]; )
911
- g2.nextBytes(h2);
912
- c2[--b2] = h2[0];
551
+ function hexToBase64Url(hex) {
552
+ const buffer = Buffer.from(hex, "hex");
553
+ return buffer.toString("base64url");
554
+ }
555
+ var RSAKey = class {
556
+ publicKey = null;
557
+ setPublic(modulus, exponent) {
558
+ try {
559
+ const jwkKey = {
560
+ kty: "RSA",
561
+ n: hexToBase64Url(modulus),
562
+ e: hexToBase64Url(exponent)
563
+ };
564
+ this.publicKey = import_crypto.default.createPublicKey({
565
+ key: jwkKey,
566
+ format: "jwk"
567
+ });
568
+ } catch (error) {
569
+ console.error("Failed to create public key:", error);
570
+ this.publicKey = null;
913
571
  }
914
- return c2[--b2] = 2, c2[--b2] = 0, new d(c2);
915
- }
916
- function db() {
917
- this.n = null, this.e = 0, this.d = null, this.p = null, this.q = null, this.dmp1 = null, this.dmq1 = null, this.coeff = null;
918
- }
919
- function eb(a2, b2) {
920
- null != a2 && null != b2 && a2.length > 0 && b2.length > 0 ? (this.n = bb(a2, 16), this.e = parseInt(b2, 16)) : console.error("net error");
921
572
  }
922
- function fb(a2) {
923
- return a2.modPowInt(this.e, this.n);
924
- }
925
- function gb(a2) {
926
- var b2 = cb(a2, this.n.bitLength() + 7 >> 3);
927
- if (null == b2)
928
- return null;
929
- var c2 = this.doPublic(b2);
930
- if (null == c2)
573
+ encrypt(text) {
574
+ if (!this.publicKey) {
575
+ console.error("Public key not set");
931
576
  return null;
932
- var d2 = c2.toString(16);
933
- return 0 == (1 & d2.length) ? d2 : "0" + d2;
934
- }
935
- var hb, ib = 244837814094590, jb = 15715070 == (16777215 & ib);
936
- 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;
937
- var kb = 52;
938
- d.prototype.FV = Math.pow(2, kb), d.prototype.F1 = kb - hb, d.prototype.F2 = 2 * hb - kb;
939
- var lb, mb, nb = "0123456789abcdefghijklmnopqrstuvwxyz", ob = new Array();
940
- for (lb = "0".charCodeAt(0), mb = 0; 9 >= mb; ++mb)
941
- ob[lb++] = mb;
942
- for (lb = "a".charCodeAt(0), mb = 10; 36 > mb; ++mb)
943
- ob[lb++] = mb;
944
- for (lb = "A".charCodeAt(0), mb = 10; 36 > mb; ++mb)
945
- ob[lb++] = mb;
946
- 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;
947
- var pb, qb, rb, sb = 256;
948
- if (null == qb) {
949
- qb = new Array(), rb = 0;
950
- var tb;
951
- if (window.crypto && window.crypto.getRandomValues) {
952
- var ub = new Uint8Array(32);
953
- for (window.crypto.getRandomValues(ub), tb = 0; 32 > tb; ++tb)
954
- qb[rb++] = ub[tb];
955
577
  }
956
- if ("Netscape" == navigator.appName && navigator.appVersion < "5" && window.crypto) {
957
- var vb = window.crypto.random(32);
958
- for (tb = 0; tb < vb.length; ++tb)
959
- qb[rb++] = 255 & vb.charCodeAt(tb);
578
+ try {
579
+ const buffer = Buffer.from(text, "utf-8");
580
+ const encrypted = import_crypto.default.publicEncrypt(
581
+ {
582
+ key: this.publicKey,
583
+ padding: import_crypto.default.constants.RSA_PKCS1_PADDING
584
+ },
585
+ buffer
586
+ );
587
+ return encrypted.toString("hex");
588
+ } catch (error) {
589
+ console.error("RSA encryption failed:", error);
590
+ return null;
960
591
  }
961
- for (; sb > rb; )
962
- tb = Math.floor(65536 * Math.random()), qb[rb++] = tb >>> 8, qb[rb++] = 255 & tb;
963
- rb = 0, Z();
964
592
  }
965
- ab.prototype.nextBytes = _, db.prototype.doPublic = fb, db.prototype.setPublic = eb, db.prototype.encrypt = gb, c.exports = {
966
- RSAKey: db
967
- };
968
- });
969
- var rsalib_default = rsa;
593
+ };
970
594
 
971
595
  // src/utils/publicKey.ts
972
596
  var getPublicKey = async () => {
@@ -993,7 +617,6 @@ function URLParams($) {
993
617
  }
994
618
 
995
619
  // src/modules/login_np.ts
996
- var RSAKey = rsalib_default.RSAKey;
997
620
  function randomString() {
998
621
  const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
999
622
  return random.toLowerCase();
@@ -1023,22 +646,25 @@ var loginNP = {
1023
646
  if (!modulus || !publicExponent) {
1024
647
  return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
1025
648
  }
1026
- var rsa2 = new RSAKey();
1027
- rsa2.setPublic(modulus, publicExponent);
1028
- const rsa_pwd = rsa2.encrypt(password);
1029
- const rsa_username = rsa2.encrypt(username);
649
+ var rsa = new RSAKey();
650
+ rsa.setPublic(modulus, publicExponent);
651
+ const rsa_pwd = rsa.encrypt(password);
652
+ const rsa_username = rsa.encrypt(username);
1030
653
  const fakeFingerprint = randomString();
1031
654
  $.fingerPrint = fakeFingerprint;
1032
655
  $.fingerPrintDetail = fakeFingerprint;
1033
- $.enpassword = rsa_pwd;
1034
- $.loginID = rsa_username;
656
+ $.enpassword = rsa_pwd || "";
657
+ $.loginID = rsa_username || "";
1035
658
  const form = URLParams($);
1036
659
  const res = await fetch(
1037
660
  `https://passport.migu.cn/authn`,
1038
661
  {
1039
662
  method: "POST",
1040
663
  headers: {
1041
- "Host": "passport.migu.cn"
664
+ "Host": "passport.migu.cn",
665
+ "Content-Type": "application/x-www-form-urlencoded",
666
+ "Referer": "https://passport.migu.cn/login",
667
+ "Origin": "https://passport.migu.cn"
1042
668
  },
1043
669
  body: form
1044
670
  }
@@ -1187,7 +813,6 @@ var getTodayRecommend = async (pacmtoken) => {
1187
813
  };
1188
814
 
1189
815
  // src/modules/login_sim.ts
1190
- var RSAKey2 = rsalib_default.RSAKey;
1191
816
  function randomString2() {
1192
817
  const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
1193
818
  return random.toLowerCase();
@@ -1210,21 +835,23 @@ var loginSim = {
1210
835
  if (!modulus || !publicExponent) {
1211
836
  return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
1212
837
  }
1213
- const rsa2 = new RSAKey2();
1214
- rsa2.setPublic(modulus, publicExponent);
1215
- const encPhone = rsa2.encrypt(phone);
838
+ const rsa = new RSAKey();
839
+ rsa.setPublic(modulus, publicExponent);
840
+ const encPhone = rsa.encrypt(phone);
1216
841
  const fakeFingerprint = randomString2();
1217
842
  $.fingerPrint = fakeFingerprint;
1218
843
  $.fingerPrintDetail = fakeFingerprint;
1219
- $.encMsisdn = encPhone;
844
+ $.encMsisdn = encPhone || "";
1220
845
  const form = URLParams($);
1221
846
  const send = await fetch(
1222
847
  `https://passport.migu.cn/api/simauth/send`,
1223
848
  {
1224
849
  method: "POST",
1225
850
  headers: {
1226
- //'User-Agent': ua,
1227
- "Host": "passport.migu.cn"
851
+ "Host": "passport.migu.cn",
852
+ "Content-Type": "application/x-www-form-urlencoded",
853
+ "Referer": "https://passport.migu.cn/login",
854
+ "Origin": "https://passport.migu.cn"
1228
855
  },
1229
856
  body: form
1230
857
  }
@@ -1253,7 +880,12 @@ var loginSim = {
1253
880
  `https://passport.migu.cn/api/simauth/query`,
1254
881
  {
1255
882
  method: "POST",
1256
- headers: { "Host": "passport.migu.cn" },
883
+ headers: {
884
+ "Host": "passport.migu.cn",
885
+ "Content-Type": "application/x-www-form-urlencoded",
886
+ "Referer": "https://passport.migu.cn/login",
887
+ "Origin": "https://passport.migu.cn"
888
+ },
1257
889
  body: form
1258
890
  }
1259
891
  );
@@ -1361,9 +993,9 @@ var YDRZ = {
1361
993
  return Math.floor(Math.random() * (min - max) + max);
1362
994
  },
1363
995
  getUA() {
1364
- const ua = nav.userAgent, l = [
996
+ const ua2 = nav.userAgent, l = [
1365
997
  nav.platform,
1366
- ua,
998
+ ua2,
1367
999
  nav.appVersion,
1368
1000
  nav.cookieEnabled,
1369
1001
  void 0,
@@ -1374,7 +1006,7 @@ var YDRZ = {
1374
1006
  nav.availHeight,
1375
1007
  nav.colorDepth,
1376
1008
  nav.timezoneOffset
1377
- ], key = l.join("@@"), finalUA = ua.length > 100 ? ua.substring(0, 100) : ua;
1009
+ ], key = l.join("@@"), finalUA = ua2.length > 100 ? ua2.substring(0, 100) : ua2;
1378
1010
  return nav.platform + "@@" + finalUA + "@@" + md5(key);
1379
1011
  },
1380
1012
  uaE(str) {
@@ -1513,12 +1145,132 @@ var loginOneClick = {
1513
1145
  authn
1514
1146
  };
1515
1147
 
1148
+ // src/modules/login_phone.ts
1149
+ function randomString3() {
1150
+ const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
1151
+ return random.toLowerCase();
1152
+ }
1153
+ var loginPhone = {
1154
+ //获取验证码
1155
+ async getMsgCode(phone) {
1156
+ var $ = {
1157
+ "isAsync": true,
1158
+ "msisdn": "",
1159
+ "captcha": "",
1160
+ "sourceID": "220029",
1161
+ "imgcodeType": "2",
1162
+ "fingerPrint": "",
1163
+ "fingerPrintDetail": "",
1164
+ "_": ""
1165
+ };
1166
+ const result = await getPublicKey();
1167
+ const { publicExponent = "", modulus = "" } = result;
1168
+ var c = new RSAKey();
1169
+ c.setPublic(modulus, publicExponent);
1170
+ $.msisdn = c.encrypt(phone) || "";
1171
+ if (!$.msisdn) return { error: "encrypt error" };
1172
+ const fakeFingerprint = randomString3();
1173
+ $.fingerPrint = fakeFingerprint;
1174
+ $.fingerPrintDetail = fakeFingerprint;
1175
+ $._ = (/* @__PURE__ */ new Date()).getTime().toString();
1176
+ const query = URLParams($);
1177
+ const res = await fetch(
1178
+ `https://passport.migu.cn/login/dynamicpassword?${query}`,
1179
+ {
1180
+ method: "GET",
1181
+ headers: {
1182
+ "Host": "passport.migu.cn",
1183
+ "Referer": "https://passport.migu.cn/login",
1184
+ "Origin": "https://passport.migu.cn"
1185
+ }
1186
+ }
1187
+ );
1188
+ if (!res.ok) return { error: "gmc e" };
1189
+ const data = await res.json();
1190
+ return data;
1191
+ },
1192
+ //登陆
1193
+ async authn(phone, msgCode) {
1194
+ var $ = {
1195
+ "isAsync": true,
1196
+ "msisdn": "",
1197
+ "dynamicPassword": "",
1198
+ "captcha": "",
1199
+ "appType": "",
1200
+ "securityCode": "7619",
1201
+ "sourceID": "220029",
1202
+ "imgcodeType": "2",
1203
+ "fingerPrint": "",
1204
+ "fingerPrintDetail": ""
1205
+ };
1206
+ const result = await getPublicKey();
1207
+ const { publicExponent = "", modulus = "" } = result;
1208
+ var c = new RSAKey();
1209
+ c.setPublic(modulus, publicExponent);
1210
+ $.msisdn = c.encrypt(phone) || "";
1211
+ $.dynamicPassword = c.encrypt(msgCode) || "";
1212
+ if (!$.msisdn || !$.dynamicPassword) return { error: "encrypt error" };
1213
+ const fakeFingerprint = randomString3();
1214
+ $.fingerPrint = fakeFingerprint;
1215
+ $.fingerPrintDetail = fakeFingerprint;
1216
+ const form = URLParams($);
1217
+ const res = await fetch(
1218
+ `https://passport.migu.cn/authn/dynamicpassword`,
1219
+ {
1220
+ method: "POST",
1221
+ headers: {
1222
+ "Host": "passport.migu.cn",
1223
+ "Content-Type": "application/x-www-form-urlencoded",
1224
+ "Referer": "https://passport.migu.cn/login",
1225
+ "Origin": "https://passport.migu.cn"
1226
+ },
1227
+ body: form
1228
+ }
1229
+ );
1230
+ if (!res.ok) return { error: "gmc e" };
1231
+ const data = await res.json();
1232
+ return data;
1233
+ }
1234
+ };
1235
+
1236
+ // src/modules/mv_recommend.ts
1237
+ var getMVRecommend = async (mvContentId, page = 1) => {
1238
+ return await h5fetch(`https://c.musicapp.migu.cn/MIGUM3.0/v3.0/content/recommend-mv?resourceId=${mvContentId}&pageNumber=${page}&resourceType=D`);
1239
+ };
1240
+
1241
+ // src/utils/index.ts
1242
+ var utils_exports = {};
1243
+ __export(utils_exports, {
1244
+ RSAKey: () => RSAKey,
1245
+ URLParams: () => URLParams,
1246
+ getDeviceId: () => getDeviceId,
1247
+ getPublicKey: () => getPublicKey,
1248
+ randomUA: () => randomUA,
1249
+ ua: () => ua
1250
+ });
1251
+
1252
+ // src/utils/ua.ts
1253
+ var ua = [
1254
+ "Mozilla/5.0 (Linux; Android 9; Redmi Note 7 Build/PKQ1.180904.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/72.0.3626.121 Mobile Safari/537.36",
1255
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0",
1256
+ "Mozilla/5.0 (Linux; Android 9; Redmi Note 7 Build/PKQ1.180904.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/74.0.3729.136 Mobile Safari/537.36",
1257
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_1 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Mobile/15B150 /sa-sdk-ios/sensors-verify/sc.baertt.com?production ",
1258
+ "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/534.31 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/534.31"
1259
+ ];
1260
+ var randomUA = () => {
1261
+ const i = Math.floor(Math.random() * 5);
1262
+ return ua[i];
1263
+ };
1264
+
1516
1265
  // src/index.ts
1517
1266
  function createClient() {
1518
1267
  return modules_exports;
1519
1268
  }
1520
1269
  // Annotate the CommonJS export names for ESM import in node:
1521
1270
  0 && (module.exports = {
1271
+ MiguUtils,
1272
+ RSAKey,
1273
+ URLParams,
1522
1274
  YDRZ,
1523
1275
  checkCanListen,
1524
1276
  checkToken,
@@ -1526,12 +1278,15 @@ function createClient() {
1526
1278
  getAlbumInfo,
1527
1279
  getAlbumSong,
1528
1280
  getComment,
1281
+ getDeviceId,
1282
+ getMVRecommend,
1529
1283
  getMvHls,
1530
1284
  getMvInfo,
1531
1285
  getOpNum,
1532
1286
  getPacmToken,
1533
1287
  getPlaylistInfo,
1534
1288
  getPlaylistSong,
1289
+ getPublicKey,
1535
1290
  getRadioRecommend,
1536
1291
  getRankIndex,
1537
1292
  getRankInfo,
@@ -1559,9 +1314,11 @@ function createClient() {
1559
1314
  getVersion,
1560
1315
  loginNP,
1561
1316
  loginOneClick,
1317
+ loginPhone,
1562
1318
  loginSim,
1563
1319
  modules,
1564
1320
  queryUserInfo,
1321
+ randomUA,
1565
1322
  searchAlbum,
1566
1323
  searchConcert,
1567
1324
  searchRbt,
@@ -1569,6 +1326,7 @@ function createClient() {
1569
1326
  searchSong,
1570
1327
  searchSuggest,
1571
1328
  searchTicket,
1572
- searchVideo
1329
+ searchVideo,
1330
+ ua
1573
1331
  });
1574
1332
  //# sourceMappingURL=index.cjs.map