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.js CHANGED
@@ -13,6 +13,7 @@ __export(modules_exports, {
13
13
  getAlbumInfo: () => getAlbumInfo,
14
14
  getAlbumSong: () => getAlbumSong,
15
15
  getComment: () => getComment,
16
+ getMVRecommend: () => getMVRecommend,
16
17
  getMvHls: () => getMvHls,
17
18
  getMvInfo: () => getMvInfo,
18
19
  getOpNum: () => getOpNum,
@@ -46,6 +47,7 @@ __export(modules_exports, {
46
47
  getVersion: () => getVersion,
47
48
  loginNP: () => loginNP,
48
49
  loginOneClick: () => loginOneClick,
50
+ loginPhone: () => loginPhone,
49
51
  loginSim: () => loginSim,
50
52
  queryUserInfo: () => queryUserInfo,
51
53
  searchAlbum: () => searchAlbum,
@@ -423,13 +425,13 @@ var decryptData2 = async (blob) => {
423
425
  };
424
426
 
425
427
  // src/modules/version.ts
426
- var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_migu") => {
428
+ var getVersion = async (channel = "0146921", version = "8.4.0", ua2 = "Android_migu") => {
427
429
  return await h5fetch(
428
430
  `http://app.c.nf.migu.cn/MIGUM2.0/resource/client/version/v1.0`,
429
431
  {
430
432
  headers: {
431
433
  "channel": channel,
432
- "ua": ua,
434
+ "ua": ua2,
433
435
  "version": version
434
436
  }
435
437
  }
@@ -437,8 +439,8 @@ var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_mi
437
439
  };
438
440
 
439
441
  // src/modules/mv_info.ts
440
- var getMvInfo = async (mvIds) => {
441
- return h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvIds}&resourceType=D&needSimple=01`);
442
+ var getMvInfo = async (mvContentId) => {
443
+ return await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvContentId}&resourceType=D&needSimple=01`);
442
444
  };
443
445
 
444
446
  // src/modules/mv_hls.ts
@@ -455,438 +457,51 @@ var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012",
455
457
  );
456
458
  };
457
459
 
458
- // src/utils/rsalib.js
460
+ // src/utils/rsalib.ts
459
461
  import crypto from "crypto";
460
- var rsa;
461
- globalThis.define = function(id, deps, factory) {
462
- let req = () => ({});
463
- let exp = {};
464
- let mod = { exports: exp };
465
- factory(req, exp, mod);
466
- rsa = mod.exports;
467
- };
468
- globalThis.window = {};
469
- Object.defineProperty(globalThis, "navigator", {
470
- writable: true,
471
- value: {
472
- appName: "Netscape",
473
- appVersion: "5.0 (Node.js)"
474
- }
475
- });
476
- globalThis.window.navigator = globalThis.navigator;
477
- globalThis.window.crypto = {
478
- getRandomValues: function(arr) {
479
- const bytes = crypto.randomBytes(arr.length);
480
- for (let i = 0; i < arr.length; i++) {
481
- arr[i] = bytes[i];
482
- }
483
- return arr;
484
- },
485
- random: function(len) {
486
- const bytes = crypto.randomBytes(len);
487
- return Array.from(bytes, (b) => String.fromCharCode(b)).join("");
488
- }
489
- };
490
- define("lib/rsa/rsa", [], function(a, b, c) {
491
- function d(a2, b2, c2) {
492
- null != a2 && ("number" == typeof a2 ? this.fromNumber(a2, b2, c2) : null == b2 && "string" != typeof a2 ? this.fromString(a2, 256) : this.fromString(a2, b2));
493
- }
494
- function e() {
495
- return new d(null);
496
- }
497
- function f(a2, b2, c2, d2, e2, f2) {
498
- for (; --f2 >= 0; ) {
499
- var g2 = b2 * this[a2++] + c2[d2] + e2;
500
- e2 = Math.floor(g2 / 67108864), c2[d2++] = 67108863 & g2;
501
- }
502
- return e2;
503
- }
504
- function g(a2, b2, c2, d2, e2, f2) {
505
- for (var g2 = 32767 & b2, h2 = b2 >> 15; --f2 >= 0; ) {
506
- var i2 = 32767 & this[a2], j2 = this[a2++] >> 15, k2 = h2 * i2 + j2 * g2;
507
- i2 = g2 * i2 + ((32767 & k2) << 15) + c2[d2] + (1073741823 & e2), e2 = (i2 >>> 30) + (k2 >>> 15) + h2 * j2 + (e2 >>> 30), c2[d2++] = 1073741823 & i2;
508
- }
509
- return e2;
510
- }
511
- function h(a2, b2, c2, d2, e2, f2) {
512
- for (var g2 = 16383 & b2, h2 = b2 >> 14; --f2 >= 0; ) {
513
- var i2 = 16383 & this[a2], j2 = this[a2++] >> 14, k2 = h2 * i2 + j2 * g2;
514
- i2 = g2 * i2 + ((16383 & k2) << 14) + c2[d2] + e2, e2 = (i2 >> 28) + (k2 >> 14) + h2 * j2, c2[d2++] = 268435455 & i2;
515
- }
516
- return e2;
517
- }
518
- function i(a2) {
519
- return nb.charAt(a2);
520
- }
521
- function j(a2, b2) {
522
- var c2 = ob[a2.charCodeAt(b2)];
523
- return null == c2 ? -1 : c2;
524
- }
525
- function k(a2) {
526
- for (var b2 = this.t - 1; b2 >= 0; --b2)
527
- a2[b2] = this[b2];
528
- a2.t = this.t, a2.s = this.s;
529
- }
530
- function l(a2) {
531
- this.t = 1, this.s = 0 > a2 ? -1 : 0, a2 > 0 ? this[0] = a2 : -1 > a2 ? this[0] = a2 + this.DV : this.t = 0;
532
- }
533
- function m(a2) {
534
- var b2 = e();
535
- return b2.fromInt(a2), b2;
536
- }
537
- function n(a2, b2) {
538
- var c2;
539
- if (16 == b2)
540
- c2 = 4;
541
- else if (8 == b2)
542
- c2 = 3;
543
- else if (256 == b2)
544
- c2 = 8;
545
- else if (2 == b2)
546
- c2 = 1;
547
- else if (32 == b2)
548
- c2 = 5;
549
- else {
550
- if (4 != b2)
551
- return void this.fromRadix(a2, b2);
552
- c2 = 2;
553
- }
554
- this.t = 0, this.s = 0;
555
- for (var e2 = a2.length, f2 = false, g2 = 0; --e2 >= 0; ) {
556
- var h2 = 8 == c2 ? 255 & a2[e2] : j(a2, e2);
557
- 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));
558
- }
559
- 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);
560
- }
561
- function o() {
562
- for (var a2 = this.s & this.DM; this.t > 0 && this[this.t - 1] == a2; )
563
- --this.t;
564
- }
565
- function p(a2) {
566
- if (this.s < 0)
567
- return "-" + this.negate().toString(a2);
568
- var b2;
569
- if (16 == a2)
570
- b2 = 4;
571
- else if (8 == a2)
572
- b2 = 3;
573
- else if (2 == a2)
574
- b2 = 1;
575
- else if (32 == a2)
576
- b2 = 5;
577
- else {
578
- if (4 != a2)
579
- return this.toRadix(a2);
580
- b2 = 2;
581
- }
582
- var c2, d2 = (1 << b2) - 1, e2 = false, f2 = "", g2 = this.t, h2 = this.DB - g2 * this.DB % b2;
583
- if (g2-- > 0)
584
- for (h2 < this.DB && (c2 = this[g2] >> h2) > 0 && (e2 = true, f2 = i(c2)); g2 >= 0; )
585
- 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));
586
- return e2 ? f2 : "0";
587
- }
588
- function q() {
589
- var a2 = e();
590
- return d.ZERO.subTo(this, a2), a2;
591
- }
592
- function r() {
593
- return this.s < 0 ? this.negate() : this;
594
- }
595
- function s(a2) {
596
- var b2 = this.s - a2.s;
597
- if (0 != b2)
598
- return b2;
599
- var c2 = this.t;
600
- if (b2 = c2 - a2.t, 0 != b2)
601
- return this.s < 0 ? -b2 : b2;
602
- for (; --c2 >= 0; )
603
- if (0 != (b2 = this[c2] - a2[c2]))
604
- return b2;
605
- return 0;
606
- }
607
- function t(a2) {
608
- var b2, c2 = 1;
609
- 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;
610
- }
611
- function u() {
612
- return this.t <= 0 ? 0 : this.DB * (this.t - 1) + t(this[this.t - 1] ^ this.s & this.DM);
613
- }
614
- function v(a2, b2) {
615
- var c2;
616
- for (c2 = this.t - 1; c2 >= 0; --c2)
617
- b2[c2 + a2] = this[c2];
618
- for (c2 = a2 - 1; c2 >= 0; --c2)
619
- b2[c2] = 0;
620
- b2.t = this.t + a2, b2.s = this.s;
621
- }
622
- function w(a2, b2) {
623
- for (var c2 = a2; c2 < this.t; ++c2)
624
- b2[c2 - a2] = this[c2];
625
- b2.t = Math.max(this.t - a2, 0), b2.s = this.s;
626
- }
627
- function x(a2, b2) {
628
- 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;
629
- for (c2 = this.t - 1; c2 >= 0; --c2)
630
- b2[c2 + g2 + 1] = this[c2] >> e2 | h2, h2 = (this[c2] & f2) << d2;
631
- for (c2 = g2 - 1; c2 >= 0; --c2)
632
- b2[c2] = 0;
633
- b2[g2] = h2, b2.t = this.t + g2 + 1, b2.s = this.s, b2.clamp();
634
- }
635
- function y(a2, b2) {
636
- b2.s = this.s;
637
- var c2 = Math.floor(a2 / this.DB);
638
- if (c2 >= this.t)
639
- return void (b2.t = 0);
640
- var d2 = a2 % this.DB, e2 = this.DB - d2, f2 = (1 << d2) - 1;
641
- b2[0] = this[c2] >> d2;
642
- for (var g2 = c2 + 1; g2 < this.t; ++g2)
643
- b2[g2 - c2 - 1] |= (this[g2] & f2) << e2, b2[g2 - c2] = this[g2] >> d2;
644
- d2 > 0 && (b2[this.t - c2 - 1] |= (this.s & f2) << e2), b2.t = this.t - c2, b2.clamp();
645
- }
646
- function z(a2, b2) {
647
- for (var c2 = 0, d2 = 0, e2 = Math.min(a2.t, this.t); e2 > c2; )
648
- d2 += this[c2] - a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
649
- if (a2.t < this.t) {
650
- for (d2 -= a2.s; c2 < this.t; )
651
- d2 += this[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
652
- d2 += this.s;
653
- } else {
654
- for (d2 += this.s; c2 < a2.t; )
655
- d2 -= a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
656
- d2 -= a2.s;
657
- }
658
- b2.s = 0 > d2 ? -1 : 0, -1 > d2 ? b2[c2++] = this.DV + d2 : d2 > 0 && (b2[c2++] = d2), b2.t = c2, b2.clamp();
659
- }
660
- function A(a2, b2) {
661
- var c2 = this.abs(), e2 = a2.abs(), f2 = c2.t;
662
- for (b2.t = f2 + e2.t; --f2 >= 0; )
663
- b2[f2] = 0;
664
- for (f2 = 0; f2 < e2.t; ++f2)
665
- b2[f2 + c2.t] = c2.am(0, e2[f2], b2, f2, 0, c2.t);
666
- b2.s = 0, b2.clamp(), this.s != a2.s && d.ZERO.subTo(b2, b2);
667
- }
668
- function B(a2) {
669
- for (var b2 = this.abs(), c2 = a2.t = 2 * b2.t; --c2 >= 0; )
670
- a2[c2] = 0;
671
- for (c2 = 0; c2 < b2.t - 1; ++c2) {
672
- var d2 = b2.am(c2, b2[c2], a2, 2 * c2, 0, 1);
673
- (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);
674
- }
675
- a2.t > 0 && (a2[a2.t - 1] += b2.am(c2, b2[c2], a2, 2 * c2, 0, 1)), a2.s = 0, a2.clamp();
676
- }
677
- function C(a2, b2, c2) {
678
- var f2 = a2.abs();
679
- if (!(f2.t <= 0)) {
680
- var g2 = this.abs();
681
- if (g2.t < f2.t)
682
- return null != b2 && b2.fromInt(0), void (null != c2 && this.copyTo(c2));
683
- null == c2 && (c2 = e());
684
- var h2 = e(), i2 = this.s, j2 = a2.s, k2 = this.DB - t(f2[f2.t - 1]);
685
- k2 > 0 ? (f2.lShiftTo(k2, h2), g2.lShiftTo(k2, c2)) : (f2.copyTo(h2), g2.copyTo(c2));
686
- var l2 = h2.t, m2 = h2[l2 - 1];
687
- if (0 != m2) {
688
- 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;
689
- 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; )
690
- h2[h2.t++] = 0;
691
- for (; --s2 >= 0; ) {
692
- var v2 = c2[--r2] == m2 ? this.DM : Math.floor(c2[r2] * o2 + (c2[r2 - 1] + q2) * p2);
693
- if ((c2[r2] += h2.am(0, v2, c2, s2, 0, l2)) < v2)
694
- for (h2.dlShiftTo(s2, u2), c2.subTo(u2, c2); c2[r2] < --v2; )
695
- c2.subTo(u2, c2);
696
- }
697
- 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);
698
- }
699
- }
700
- }
701
- function D(a2) {
702
- var b2 = e();
703
- return this.abs().divRemTo(a2, null, b2), this.s < 0 && b2.compareTo(d.ZERO) > 0 && a2.subTo(b2, b2), b2;
704
- }
705
- function E(a2) {
706
- this.m = a2;
707
- }
708
- function F(a2) {
709
- return a2.s < 0 || a2.compareTo(this.m) >= 0 ? a2.mod(this.m) : a2;
710
- }
711
- function G(a2) {
712
- return a2;
713
- }
714
- function H(a2) {
715
- a2.divRemTo(this.m, null, a2);
716
- }
717
- function I(a2, b2, c2) {
718
- a2.multiplyTo(b2, c2), this.reduce(c2);
719
- }
720
- function J(a2, b2) {
721
- a2.squareTo(b2), this.reduce(b2);
722
- }
723
- function K() {
724
- if (this.t < 1)
725
- return 0;
726
- var a2 = this[0];
727
- if (0 == (1 & a2))
728
- return 0;
729
- var b2 = 3 & a2;
730
- 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;
731
- }
732
- function L(a2) {
733
- 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;
734
- }
735
- function M(a2) {
736
- var b2 = e();
737
- 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;
738
- }
739
- function N(a2) {
740
- var b2 = e();
741
- return a2.copyTo(b2), this.reduce(b2), b2;
742
- }
743
- function O(a2) {
744
- for (; a2.t <= this.mt2; )
745
- a2[a2.t++] = 0;
746
- for (var b2 = 0; b2 < this.m.t; ++b2) {
747
- var c2 = 32767 & a2[b2], d2 = c2 * this.mpl + ((c2 * this.mph + (a2[b2] >> 15) * this.mpl & this.um) << 15) & a2.DM;
748
- for (c2 = b2 + this.m.t, a2[c2] += this.m.am(0, d2, a2, b2, 0, this.m.t); a2[c2] >= a2.DV; )
749
- a2[c2] -= a2.DV, a2[++c2]++;
750
- }
751
- a2.clamp(), a2.drShiftTo(this.m.t, a2), a2.compareTo(this.m) >= 0 && a2.subTo(this.m, a2);
752
- }
753
- function P(a2, b2) {
754
- a2.squareTo(b2), this.reduce(b2);
755
- }
756
- function Q(a2, b2, c2) {
757
- a2.multiplyTo(b2, c2), this.reduce(c2);
758
- }
759
- function R() {
760
- return 0 == (this.t > 0 ? 1 & this[0] : this.s);
761
- }
762
- function S(a2, b2) {
763
- if (a2 > 4294967295 || 1 > a2)
764
- return d.ONE;
765
- var c2 = e(), f2 = e(), g2 = b2.convert(this), h2 = t(a2) - 1;
766
- for (g2.copyTo(c2); --h2 >= 0; )
767
- if (b2.sqrTo(c2, f2), (a2 & 1 << h2) > 0)
768
- b2.mulTo(f2, g2, c2);
769
- else {
770
- var i2 = c2;
771
- c2 = f2, f2 = i2;
772
- }
773
- return b2.revert(c2);
774
- }
775
- function T(a2, b2) {
776
- var c2;
777
- return c2 = 256 > a2 || b2.isEven() ? new E(b2) : new L(b2), this.exp(a2, c2);
778
- }
779
- function U() {
780
- this.i = 0, this.j = 0, this.S = new Array();
781
- }
782
- function V(a2) {
783
- var b2, c2, d2;
784
- for (b2 = 0; 256 > b2; ++b2)
785
- this.S[b2] = b2;
786
- for (c2 = 0, b2 = 0; 256 > b2; ++b2)
787
- c2 = c2 + this.S[b2] + a2[b2 % a2.length] & 255, d2 = this.S[b2], this.S[b2] = this.S[c2], this.S[c2] = d2;
788
- this.i = 0, this.j = 0;
789
- }
790
- function W() {
791
- var a2;
792
- 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];
793
- }
794
- function X() {
795
- return new U();
796
- }
797
- function Y(a2) {
798
- qb[rb++] ^= 255 & a2, qb[rb++] ^= a2 >> 8 & 255, qb[rb++] ^= a2 >> 16 & 255, qb[rb++] ^= a2 >> 24 & 255, rb >= sb && (rb -= sb);
799
- }
800
- function Z() {
801
- Y((/* @__PURE__ */ new Date()).getTime());
802
- }
803
- function $() {
804
- if (null == pb) {
805
- for (Z(), pb = X(), pb.init(qb), rb = 0; rb < qb.length; ++rb)
806
- qb[rb] = 0;
807
- rb = 0;
808
- }
809
- return pb.next();
810
- }
811
- function _(a2) {
812
- var b2;
813
- for (b2 = 0; b2 < a2.length; ++b2)
814
- a2[b2] = $();
815
- }
816
- function ab() {
817
- }
818
- function bb(a2, b2) {
819
- return new d(a2, b2);
820
- }
821
- function cb(a2, b2) {
822
- if (b2 < a2.length + 11)
823
- return console.error("Message too long for RSA"), null;
824
- for (var c2 = new Array(), e2 = a2.length - 1; e2 >= 0 && b2 > 0; ) {
825
- var f2 = a2.charCodeAt(e2--);
826
- 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);
827
- }
828
- c2[--b2] = 0;
829
- for (var g2 = new ab(), h2 = new Array(); b2 > 2; ) {
830
- for (h2[0] = 0; 0 == h2[0]; )
831
- g2.nextBytes(h2);
832
- c2[--b2] = h2[0];
462
+ function hexToBase64Url(hex) {
463
+ const buffer = Buffer.from(hex, "hex");
464
+ return buffer.toString("base64url");
465
+ }
466
+ var RSAKey = class {
467
+ publicKey = null;
468
+ setPublic(modulus, exponent) {
469
+ try {
470
+ const jwkKey = {
471
+ kty: "RSA",
472
+ n: hexToBase64Url(modulus),
473
+ e: hexToBase64Url(exponent)
474
+ };
475
+ this.publicKey = crypto.createPublicKey({
476
+ key: jwkKey,
477
+ format: "jwk"
478
+ });
479
+ } catch (error) {
480
+ console.error("Failed to create public key:", error);
481
+ this.publicKey = null;
833
482
  }
834
- return c2[--b2] = 2, c2[--b2] = 0, new d(c2);
835
- }
836
- function db() {
837
- this.n = null, this.e = 0, this.d = null, this.p = null, this.q = null, this.dmp1 = null, this.dmq1 = null, this.coeff = null;
838
- }
839
- function eb(a2, b2) {
840
- null != a2 && null != b2 && a2.length > 0 && b2.length > 0 ? (this.n = bb(a2, 16), this.e = parseInt(b2, 16)) : console.error("net error");
841
483
  }
842
- function fb(a2) {
843
- return a2.modPowInt(this.e, this.n);
844
- }
845
- function gb(a2) {
846
- var b2 = cb(a2, this.n.bitLength() + 7 >> 3);
847
- if (null == b2)
848
- return null;
849
- var c2 = this.doPublic(b2);
850
- if (null == c2)
484
+ encrypt(text) {
485
+ if (!this.publicKey) {
486
+ console.error("Public key not set");
851
487
  return null;
852
- var d2 = c2.toString(16);
853
- return 0 == (1 & d2.length) ? d2 : "0" + d2;
854
- }
855
- var hb, ib = 244837814094590, jb = 15715070 == (16777215 & ib);
856
- 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;
857
- var kb = 52;
858
- d.prototype.FV = Math.pow(2, kb), d.prototype.F1 = kb - hb, d.prototype.F2 = 2 * hb - kb;
859
- var lb, mb, nb = "0123456789abcdefghijklmnopqrstuvwxyz", ob = new Array();
860
- for (lb = "0".charCodeAt(0), mb = 0; 9 >= mb; ++mb)
861
- ob[lb++] = mb;
862
- for (lb = "a".charCodeAt(0), mb = 10; 36 > mb; ++mb)
863
- ob[lb++] = mb;
864
- for (lb = "A".charCodeAt(0), mb = 10; 36 > mb; ++mb)
865
- ob[lb++] = mb;
866
- 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;
867
- var pb, qb, rb, sb = 256;
868
- if (null == qb) {
869
- qb = new Array(), rb = 0;
870
- var tb;
871
- if (window.crypto && window.crypto.getRandomValues) {
872
- var ub = new Uint8Array(32);
873
- for (window.crypto.getRandomValues(ub), tb = 0; 32 > tb; ++tb)
874
- qb[rb++] = ub[tb];
875
488
  }
876
- if ("Netscape" == navigator.appName && navigator.appVersion < "5" && window.crypto) {
877
- var vb = window.crypto.random(32);
878
- for (tb = 0; tb < vb.length; ++tb)
879
- qb[rb++] = 255 & vb.charCodeAt(tb);
489
+ try {
490
+ const buffer = Buffer.from(text, "utf-8");
491
+ const encrypted = crypto.publicEncrypt(
492
+ {
493
+ key: this.publicKey,
494
+ padding: crypto.constants.RSA_PKCS1_PADDING
495
+ },
496
+ buffer
497
+ );
498
+ return encrypted.toString("hex");
499
+ } catch (error) {
500
+ console.error("RSA encryption failed:", error);
501
+ return null;
880
502
  }
881
- for (; sb > rb; )
882
- tb = Math.floor(65536 * Math.random()), qb[rb++] = tb >>> 8, qb[rb++] = 255 & tb;
883
- rb = 0, Z();
884
503
  }
885
- ab.prototype.nextBytes = _, db.prototype.doPublic = fb, db.prototype.setPublic = eb, db.prototype.encrypt = gb, c.exports = {
886
- RSAKey: db
887
- };
888
- });
889
- var rsalib_default = rsa;
504
+ };
890
505
 
891
506
  // src/utils/publicKey.ts
892
507
  var getPublicKey = async () => {
@@ -913,7 +528,6 @@ function URLParams($) {
913
528
  }
914
529
 
915
530
  // src/modules/login_np.ts
916
- var RSAKey = rsalib_default.RSAKey;
917
531
  function randomString() {
918
532
  const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
919
533
  return random.toLowerCase();
@@ -943,22 +557,25 @@ var loginNP = {
943
557
  if (!modulus || !publicExponent) {
944
558
  return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
945
559
  }
946
- var rsa2 = new RSAKey();
947
- rsa2.setPublic(modulus, publicExponent);
948
- const rsa_pwd = rsa2.encrypt(password);
949
- const rsa_username = rsa2.encrypt(username);
560
+ var rsa = new RSAKey();
561
+ rsa.setPublic(modulus, publicExponent);
562
+ const rsa_pwd = rsa.encrypt(password);
563
+ const rsa_username = rsa.encrypt(username);
950
564
  const fakeFingerprint = randomString();
951
565
  $.fingerPrint = fakeFingerprint;
952
566
  $.fingerPrintDetail = fakeFingerprint;
953
- $.enpassword = rsa_pwd;
954
- $.loginID = rsa_username;
567
+ $.enpassword = rsa_pwd || "";
568
+ $.loginID = rsa_username || "";
955
569
  const form = URLParams($);
956
570
  const res = await fetch(
957
571
  `https://passport.migu.cn/authn`,
958
572
  {
959
573
  method: "POST",
960
574
  headers: {
961
- "Host": "passport.migu.cn"
575
+ "Host": "passport.migu.cn",
576
+ "Content-Type": "application/x-www-form-urlencoded",
577
+ "Referer": "https://passport.migu.cn/login",
578
+ "Origin": "https://passport.migu.cn"
962
579
  },
963
580
  body: form
964
581
  }
@@ -1107,7 +724,6 @@ var getTodayRecommend = async (pacmtoken) => {
1107
724
  };
1108
725
 
1109
726
  // src/modules/login_sim.ts
1110
- var RSAKey2 = rsalib_default.RSAKey;
1111
727
  function randomString2() {
1112
728
  const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
1113
729
  return random.toLowerCase();
@@ -1130,21 +746,23 @@ var loginSim = {
1130
746
  if (!modulus || !publicExponent) {
1131
747
  return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
1132
748
  }
1133
- const rsa2 = new RSAKey2();
1134
- rsa2.setPublic(modulus, publicExponent);
1135
- const encPhone = rsa2.encrypt(phone);
749
+ const rsa = new RSAKey();
750
+ rsa.setPublic(modulus, publicExponent);
751
+ const encPhone = rsa.encrypt(phone);
1136
752
  const fakeFingerprint = randomString2();
1137
753
  $.fingerPrint = fakeFingerprint;
1138
754
  $.fingerPrintDetail = fakeFingerprint;
1139
- $.encMsisdn = encPhone;
755
+ $.encMsisdn = encPhone || "";
1140
756
  const form = URLParams($);
1141
757
  const send = await fetch(
1142
758
  `https://passport.migu.cn/api/simauth/send`,
1143
759
  {
1144
760
  method: "POST",
1145
761
  headers: {
1146
- //'User-Agent': ua,
1147
- "Host": "passport.migu.cn"
762
+ "Host": "passport.migu.cn",
763
+ "Content-Type": "application/x-www-form-urlencoded",
764
+ "Referer": "https://passport.migu.cn/login",
765
+ "Origin": "https://passport.migu.cn"
1148
766
  },
1149
767
  body: form
1150
768
  }
@@ -1173,7 +791,12 @@ var loginSim = {
1173
791
  `https://passport.migu.cn/api/simauth/query`,
1174
792
  {
1175
793
  method: "POST",
1176
- headers: { "Host": "passport.migu.cn" },
794
+ headers: {
795
+ "Host": "passport.migu.cn",
796
+ "Content-Type": "application/x-www-form-urlencoded",
797
+ "Referer": "https://passport.migu.cn/login",
798
+ "Origin": "https://passport.migu.cn"
799
+ },
1177
800
  body: form
1178
801
  }
1179
802
  );
@@ -1281,9 +904,9 @@ var YDRZ = {
1281
904
  return Math.floor(Math.random() * (min - max) + max);
1282
905
  },
1283
906
  getUA() {
1284
- const ua = nav.userAgent, l = [
907
+ const ua2 = nav.userAgent, l = [
1285
908
  nav.platform,
1286
- ua,
909
+ ua2,
1287
910
  nav.appVersion,
1288
911
  nav.cookieEnabled,
1289
912
  void 0,
@@ -1294,7 +917,7 @@ var YDRZ = {
1294
917
  nav.availHeight,
1295
918
  nav.colorDepth,
1296
919
  nav.timezoneOffset
1297
- ], key = l.join("@@"), finalUA = ua.length > 100 ? ua.substring(0, 100) : ua;
920
+ ], key = l.join("@@"), finalUA = ua2.length > 100 ? ua2.substring(0, 100) : ua2;
1298
921
  return nav.platform + "@@" + finalUA + "@@" + md5(key);
1299
922
  },
1300
923
  uaE(str) {
@@ -1433,11 +1056,131 @@ var loginOneClick = {
1433
1056
  authn
1434
1057
  };
1435
1058
 
1059
+ // src/modules/login_phone.ts
1060
+ function randomString3() {
1061
+ const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
1062
+ return random.toLowerCase();
1063
+ }
1064
+ var loginPhone = {
1065
+ //获取验证码
1066
+ async getMsgCode(phone) {
1067
+ var $ = {
1068
+ "isAsync": true,
1069
+ "msisdn": "",
1070
+ "captcha": "",
1071
+ "sourceID": "220029",
1072
+ "imgcodeType": "2",
1073
+ "fingerPrint": "",
1074
+ "fingerPrintDetail": "",
1075
+ "_": ""
1076
+ };
1077
+ const result = await getPublicKey();
1078
+ const { publicExponent = "", modulus = "" } = result;
1079
+ var c = new RSAKey();
1080
+ c.setPublic(modulus, publicExponent);
1081
+ $.msisdn = c.encrypt(phone) || "";
1082
+ if (!$.msisdn) return { error: "encrypt error" };
1083
+ const fakeFingerprint = randomString3();
1084
+ $.fingerPrint = fakeFingerprint;
1085
+ $.fingerPrintDetail = fakeFingerprint;
1086
+ $._ = (/* @__PURE__ */ new Date()).getTime().toString();
1087
+ const query = URLParams($);
1088
+ const res = await fetch(
1089
+ `https://passport.migu.cn/login/dynamicpassword?${query}`,
1090
+ {
1091
+ method: "GET",
1092
+ headers: {
1093
+ "Host": "passport.migu.cn",
1094
+ "Referer": "https://passport.migu.cn/login",
1095
+ "Origin": "https://passport.migu.cn"
1096
+ }
1097
+ }
1098
+ );
1099
+ if (!res.ok) return { error: "gmc e" };
1100
+ const data = await res.json();
1101
+ return data;
1102
+ },
1103
+ //登陆
1104
+ async authn(phone, msgCode) {
1105
+ var $ = {
1106
+ "isAsync": true,
1107
+ "msisdn": "",
1108
+ "dynamicPassword": "",
1109
+ "captcha": "",
1110
+ "appType": "",
1111
+ "securityCode": "7619",
1112
+ "sourceID": "220029",
1113
+ "imgcodeType": "2",
1114
+ "fingerPrint": "",
1115
+ "fingerPrintDetail": ""
1116
+ };
1117
+ const result = await getPublicKey();
1118
+ const { publicExponent = "", modulus = "" } = result;
1119
+ var c = new RSAKey();
1120
+ c.setPublic(modulus, publicExponent);
1121
+ $.msisdn = c.encrypt(phone) || "";
1122
+ $.dynamicPassword = c.encrypt(msgCode) || "";
1123
+ if (!$.msisdn || !$.dynamicPassword) return { error: "encrypt error" };
1124
+ const fakeFingerprint = randomString3();
1125
+ $.fingerPrint = fakeFingerprint;
1126
+ $.fingerPrintDetail = fakeFingerprint;
1127
+ const form = URLParams($);
1128
+ const res = await fetch(
1129
+ `https://passport.migu.cn/authn/dynamicpassword`,
1130
+ {
1131
+ method: "POST",
1132
+ headers: {
1133
+ "Host": "passport.migu.cn",
1134
+ "Content-Type": "application/x-www-form-urlencoded",
1135
+ "Referer": "https://passport.migu.cn/login",
1136
+ "Origin": "https://passport.migu.cn"
1137
+ },
1138
+ body: form
1139
+ }
1140
+ );
1141
+ if (!res.ok) return { error: "gmc e" };
1142
+ const data = await res.json();
1143
+ return data;
1144
+ }
1145
+ };
1146
+
1147
+ // src/modules/mv_recommend.ts
1148
+ var getMVRecommend = async (mvContentId, page = 1) => {
1149
+ return await h5fetch(`https://c.musicapp.migu.cn/MIGUM3.0/v3.0/content/recommend-mv?resourceId=${mvContentId}&pageNumber=${page}&resourceType=D`);
1150
+ };
1151
+
1152
+ // src/utils/index.ts
1153
+ var utils_exports = {};
1154
+ __export(utils_exports, {
1155
+ RSAKey: () => RSAKey,
1156
+ URLParams: () => URLParams,
1157
+ getDeviceId: () => getDeviceId,
1158
+ getPublicKey: () => getPublicKey,
1159
+ randomUA: () => randomUA,
1160
+ ua: () => ua
1161
+ });
1162
+
1163
+ // src/utils/ua.ts
1164
+ var ua = [
1165
+ "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",
1166
+ "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",
1167
+ "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",
1168
+ "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 ",
1169
+ "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"
1170
+ ];
1171
+ var randomUA = () => {
1172
+ const i = Math.floor(Math.random() * 5);
1173
+ return ua[i];
1174
+ };
1175
+
1436
1176
  // src/index.ts
1437
1177
  function createClient() {
1438
1178
  return modules_exports;
1439
1179
  }
1440
1180
  export {
1181
+ utils_exports as MiguUtils,
1182
+ RSAKey,
1183
+ URLParams,
1441
1184
  YDRZ,
1442
1185
  checkCanListen,
1443
1186
  checkToken,
@@ -1445,12 +1188,15 @@ export {
1445
1188
  getAlbumInfo,
1446
1189
  getAlbumSong,
1447
1190
  getComment,
1191
+ getDeviceId,
1192
+ getMVRecommend,
1448
1193
  getMvHls,
1449
1194
  getMvInfo,
1450
1195
  getOpNum,
1451
1196
  getPacmToken,
1452
1197
  getPlaylistInfo,
1453
1198
  getPlaylistSong,
1199
+ getPublicKey,
1454
1200
  getRadioRecommend,
1455
1201
  getRankIndex,
1456
1202
  getRankInfo,
@@ -1478,9 +1224,11 @@ export {
1478
1224
  getVersion,
1479
1225
  loginNP,
1480
1226
  loginOneClick,
1227
+ loginPhone,
1481
1228
  loginSim,
1482
1229
  modules_exports as modules,
1483
1230
  queryUserInfo,
1231
+ randomUA,
1484
1232
  searchAlbum,
1485
1233
  searchConcert,
1486
1234
  searchRbt,
@@ -1488,6 +1236,7 @@ export {
1488
1236
  searchSong,
1489
1237
  searchSuggest,
1490
1238
  searchTicket,
1491
- searchVideo
1239
+ searchVideo,
1240
+ ua
1492
1241
  };
1493
1242
  //# sourceMappingURL=index.js.map