migu-api-enhanced 1.2.4 → 1.2.6

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,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ YDRZ: () => YDRZ,
33
34
  checkCanListen: () => checkCanListen,
34
35
  checkToken: () => checkToken,
35
36
  createClient: () => createClient,
@@ -68,6 +69,7 @@ __export(index_exports, {
68
69
  getUserMyList: () => getUserMyList,
69
70
  getVersion: () => getVersion,
70
71
  loginNP: () => loginNP,
72
+ loginOneClick: () => loginOneClick,
71
73
  loginSim: () => loginSim,
72
74
  modules: () => modules_exports,
73
75
  queryUserInfo: () => queryUserInfo,
@@ -85,6 +87,7 @@ module.exports = __toCommonJS(index_exports);
85
87
  // src/modules/index.ts
86
88
  var modules_exports = {};
87
89
  __export(modules_exports, {
90
+ YDRZ: () => YDRZ,
88
91
  checkCanListen: () => checkCanListen,
89
92
  checkToken: () => checkToken,
90
93
  getAlbumInfo: () => getAlbumInfo,
@@ -122,6 +125,7 @@ __export(modules_exports, {
122
125
  getUserMyList: () => getUserMyList,
123
126
  getVersion: () => getVersion,
124
127
  loginNP: () => loginNP,
128
+ loginOneClick: () => loginOneClick,
125
129
  loginSim: () => loginSim,
126
130
  queryUserInfo: () => queryUserInfo,
127
131
  searchAlbum: () => searchAlbum,
@@ -267,10 +271,17 @@ var getRecommendPlaylist = async () => {
267
271
  };
268
272
 
269
273
  // src/utils/deviceID.ts
270
- function getDeviceId() {
271
- const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
272
- const a = `${random.substring(0, 8)}-${random.substring(8, 12)}-${random.substring(12, 16)}-${random.substring(16, 20)}-${random.substring(20)}`;
273
- return a.toUpperCase();
274
+ function getDeviceId(a, b) {
275
+ var c, d = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""), e = [];
276
+ if (b = b || d.length, a)
277
+ for (c = 0; a > c; c++)
278
+ e[c] = d[0 | Math.random() * b];
279
+ else {
280
+ var f;
281
+ for (e[8] = e[13] = e[18] = e[23] = "-", e[14] = "4", c = 0; 36 > c; c++)
282
+ e[c] || (f = 0 | 16 * Math.random(), e[c] = d[19 == c ? 3 & f | 8 : f]);
283
+ }
284
+ return e.join("");
274
285
  }
275
286
 
276
287
  // src/modules/recommend_song.ts
@@ -376,7 +387,9 @@ var getUrlV2 = async (contentId, copyrightId, resourceType = "2", pacmtoken = ""
376
387
  "timestamp": timestamp.toString(),
377
388
  "Content-Type": "application/json;charset=UTF-8",
378
389
  "referer": "https://music.migu.cn/",
379
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0"
390
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36 Edg/148.0.0.0",
391
+ "location-data": "30.6698676660,104.1229614820",
392
+ "location-info": ""
380
393
  };
381
394
  const res = await fetch(
382
395
  `https://app.c.nf.migu.cn/strategy/pc/listen/v2.0?contentId=${contentId}&copyrightId=${copyrightId}&scene=&netType=01&resourceType=${resourceType}&toneFlag=PQ`,
@@ -428,7 +441,9 @@ var getUrlH5V24 = async (contentId, copyrightId, resourceType = "2") => {
428
441
  const headers = {
429
442
  "birth": "h5page",
430
443
  "channel": "014X031",
431
- "Referer": "https://y.migu.cn/"
444
+ "Referer": "https://y.migu.cn/",
445
+ "location-data": "30.6698676660,104.1229614820",
446
+ "location-info": ""
432
447
  };
433
448
  const res = await fetch(
434
449
  `https://c.musicapp.migu.cn/strategy/listen-url/h5/v2.4?contentId=${contentId}&copyrightId=${copyrightId}&resourceType=${resourceType}&netType=01&toneFlag=PQ&scene=&lowerQualityContentId=${contentId}`,
@@ -502,30 +517,8 @@ var getVersion = async (channel = "0146921", version = "8.4.0", ua = "Android_mi
502
517
  };
503
518
 
504
519
  // src/modules/mv_info.ts
505
- var getMvInfo = async (mvIds, {
506
- needAbsoluteUrl = false
507
- }) => {
508
- const res = await h5fetch(`https://c.musicapp.migu.cn/MIGUM2.0/v1.0/content/resourceinfo.do?resourceId=${mvIds}&resourceType=D&needSimple=01`);
509
- if (!res) return { error: "\u8BF7\u6C42\u5931\u8D25" };
510
- if (res.error) return { error: res.error };
511
- const resource = res.resource || [];
512
- if (resource.length === 0) return { error: "resource\u4E0D\u5B58\u5728" };
513
- if (needAbsoluteUrl) {
514
- resource.forEach((item) => {
515
- if (!item.rateFormats) return;
516
- item.rateFormats.forEach((rateFormat) => {
517
- if (!rateFormat.url) return;
518
- if (!rateFormat.url.startsWith("http") && !rateFormat.url.startsWith("https")) {
519
- if (rateFormat.url[0] === "/" && rateFormat.url[1] !== "/") {
520
- rateFormat.absoluteUrl = `https://freevod.nf.migu.cn${rateFormat.url}`;
521
- }
522
- }
523
- });
524
- });
525
- res.resource = resource;
526
- return res;
527
- }
528
- return res;
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`);
529
522
  };
530
523
 
531
524
  // src/modules/mv_hls.ts
@@ -542,438 +535,52 @@ var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012",
542
535
  );
543
536
  };
544
537
 
545
- // src/utils/rsalib.js
538
+ // src/utils/rsalib.ts
546
539
  var import_crypto = __toESM(require("crypto"), 1);
547
- var rsa;
548
- globalThis.define = function(id, deps, factory) {
549
- let req = () => ({});
550
- let exp = {};
551
- let mod = { exports: exp };
552
- factory(req, exp, mod);
553
- rsa = mod.exports;
554
- };
555
- globalThis.window = {};
556
- Object.defineProperty(globalThis, "navigator", {
557
- writable: true,
558
- value: {
559
- appName: "Netscape",
560
- appVersion: "5.0 (Node.js)"
561
- }
562
- });
563
- globalThis.window.navigator = globalThis.navigator;
564
- globalThis.window.crypto = {
565
- getRandomValues: function(arr) {
566
- const bytes = import_crypto.default.randomBytes(arr.length);
567
- for (let i = 0; i < arr.length; i++) {
568
- arr[i] = bytes[i];
569
- }
570
- return arr;
571
- },
572
- random: function(len) {
573
- const bytes = import_crypto.default.randomBytes(len);
574
- return Array.from(bytes, (b) => String.fromCharCode(b)).join("");
575
- }
576
- };
577
- define("lib/rsa/rsa", [], function(a, b, c) {
578
- function d(a2, b2, c2) {
579
- null != a2 && ("number" == typeof a2 ? this.fromNumber(a2, b2, c2) : null == b2 && "string" != typeof a2 ? this.fromString(a2, 256) : this.fromString(a2, b2));
580
- }
581
- function e() {
582
- return new d(null);
583
- }
584
- function f(a2, b2, c2, d2, e2, f2) {
585
- for (; --f2 >= 0; ) {
586
- var g2 = b2 * this[a2++] + c2[d2] + e2;
587
- e2 = Math.floor(g2 / 67108864), c2[d2++] = 67108863 & g2;
588
- }
589
- return e2;
590
- }
591
- function g(a2, b2, c2, d2, e2, f2) {
592
- for (var g2 = 32767 & b2, h2 = b2 >> 15; --f2 >= 0; ) {
593
- var i2 = 32767 & this[a2], j2 = this[a2++] >> 15, k2 = h2 * i2 + j2 * g2;
594
- i2 = g2 * i2 + ((32767 & k2) << 15) + c2[d2] + (1073741823 & e2), e2 = (i2 >>> 30) + (k2 >>> 15) + h2 * j2 + (e2 >>> 30), c2[d2++] = 1073741823 & i2;
595
- }
596
- return e2;
597
- }
598
- function h(a2, b2, c2, d2, e2, f2) {
599
- for (var g2 = 16383 & b2, h2 = b2 >> 14; --f2 >= 0; ) {
600
- var i2 = 16383 & this[a2], j2 = this[a2++] >> 14, k2 = h2 * i2 + j2 * g2;
601
- i2 = g2 * i2 + ((16383 & k2) << 14) + c2[d2] + e2, e2 = (i2 >> 28) + (k2 >> 14) + h2 * j2, c2[d2++] = 268435455 & i2;
602
- }
603
- return e2;
604
- }
605
- function i(a2) {
606
- return nb.charAt(a2);
607
- }
608
- function j(a2, b2) {
609
- var c2 = ob[a2.charCodeAt(b2)];
610
- return null == c2 ? -1 : c2;
611
- }
612
- function k(a2) {
613
- for (var b2 = this.t - 1; b2 >= 0; --b2)
614
- a2[b2] = this[b2];
615
- a2.t = this.t, a2.s = this.s;
616
- }
617
- function l(a2) {
618
- this.t = 1, this.s = 0 > a2 ? -1 : 0, a2 > 0 ? this[0] = a2 : -1 > a2 ? this[0] = a2 + this.DV : this.t = 0;
619
- }
620
- function m(a2) {
621
- var b2 = e();
622
- return b2.fromInt(a2), b2;
623
- }
624
- function n(a2, b2) {
625
- var c2;
626
- if (16 == b2)
627
- c2 = 4;
628
- else if (8 == b2)
629
- c2 = 3;
630
- else if (256 == b2)
631
- c2 = 8;
632
- else if (2 == b2)
633
- c2 = 1;
634
- else if (32 == b2)
635
- c2 = 5;
636
- else {
637
- if (4 != b2)
638
- return void this.fromRadix(a2, b2);
639
- c2 = 2;
640
- }
641
- this.t = 0, this.s = 0;
642
- for (var e2 = a2.length, f2 = false, g2 = 0; --e2 >= 0; ) {
643
- var h2 = 8 == c2 ? 255 & a2[e2] : j(a2, e2);
644
- 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));
645
- }
646
- 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);
647
- }
648
- function o() {
649
- for (var a2 = this.s & this.DM; this.t > 0 && this[this.t - 1] == a2; )
650
- --this.t;
651
- }
652
- function p(a2) {
653
- if (this.s < 0)
654
- return "-" + this.negate().toString(a2);
655
- var b2;
656
- if (16 == a2)
657
- b2 = 4;
658
- else if (8 == a2)
659
- b2 = 3;
660
- else if (2 == a2)
661
- b2 = 1;
662
- else if (32 == a2)
663
- b2 = 5;
664
- else {
665
- if (4 != a2)
666
- return this.toRadix(a2);
667
- b2 = 2;
668
- }
669
- var c2, d2 = (1 << b2) - 1, e2 = false, f2 = "", g2 = this.t, h2 = this.DB - g2 * this.DB % b2;
670
- if (g2-- > 0)
671
- for (h2 < this.DB && (c2 = this[g2] >> h2) > 0 && (e2 = true, f2 = i(c2)); g2 >= 0; )
672
- 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));
673
- return e2 ? f2 : "0";
674
- }
675
- function q() {
676
- var a2 = e();
677
- return d.ZERO.subTo(this, a2), a2;
678
- }
679
- function r() {
680
- return this.s < 0 ? this.negate() : this;
681
- }
682
- function s(a2) {
683
- var b2 = this.s - a2.s;
684
- if (0 != b2)
685
- return b2;
686
- var c2 = this.t;
687
- if (b2 = c2 - a2.t, 0 != b2)
688
- return this.s < 0 ? -b2 : b2;
689
- for (; --c2 >= 0; )
690
- if (0 != (b2 = this[c2] - a2[c2]))
691
- return b2;
692
- return 0;
693
- }
694
- function t(a2) {
695
- var b2, c2 = 1;
696
- 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;
697
- }
698
- function u() {
699
- return this.t <= 0 ? 0 : this.DB * (this.t - 1) + t(this[this.t - 1] ^ this.s & this.DM);
700
- }
701
- function v(a2, b2) {
702
- var c2;
703
- for (c2 = this.t - 1; c2 >= 0; --c2)
704
- b2[c2 + a2] = this[c2];
705
- for (c2 = a2 - 1; c2 >= 0; --c2)
706
- b2[c2] = 0;
707
- b2.t = this.t + a2, b2.s = this.s;
708
- }
709
- function w(a2, b2) {
710
- for (var c2 = a2; c2 < this.t; ++c2)
711
- b2[c2 - a2] = this[c2];
712
- b2.t = Math.max(this.t - a2, 0), b2.s = this.s;
713
- }
714
- function x(a2, b2) {
715
- 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;
716
- for (c2 = this.t - 1; c2 >= 0; --c2)
717
- b2[c2 + g2 + 1] = this[c2] >> e2 | h2, h2 = (this[c2] & f2) << d2;
718
- for (c2 = g2 - 1; c2 >= 0; --c2)
719
- b2[c2] = 0;
720
- b2[g2] = h2, b2.t = this.t + g2 + 1, b2.s = this.s, b2.clamp();
721
- }
722
- function y(a2, b2) {
723
- b2.s = this.s;
724
- var c2 = Math.floor(a2 / this.DB);
725
- if (c2 >= this.t)
726
- return void (b2.t = 0);
727
- var d2 = a2 % this.DB, e2 = this.DB - d2, f2 = (1 << d2) - 1;
728
- b2[0] = this[c2] >> d2;
729
- for (var g2 = c2 + 1; g2 < this.t; ++g2)
730
- b2[g2 - c2 - 1] |= (this[g2] & f2) << e2, b2[g2 - c2] = this[g2] >> d2;
731
- d2 > 0 && (b2[this.t - c2 - 1] |= (this.s & f2) << e2), b2.t = this.t - c2, b2.clamp();
732
- }
733
- function z(a2, b2) {
734
- for (var c2 = 0, d2 = 0, e2 = Math.min(a2.t, this.t); e2 > c2; )
735
- d2 += this[c2] - a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
736
- if (a2.t < this.t) {
737
- for (d2 -= a2.s; c2 < this.t; )
738
- d2 += this[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
739
- d2 += this.s;
740
- } else {
741
- for (d2 += this.s; c2 < a2.t; )
742
- d2 -= a2[c2], b2[c2++] = d2 & this.DM, d2 >>= this.DB;
743
- d2 -= a2.s;
744
- }
745
- b2.s = 0 > d2 ? -1 : 0, -1 > d2 ? b2[c2++] = this.DV + d2 : d2 > 0 && (b2[c2++] = d2), b2.t = c2, b2.clamp();
746
- }
747
- function A(a2, b2) {
748
- var c2 = this.abs(), e2 = a2.abs(), f2 = c2.t;
749
- for (b2.t = f2 + e2.t; --f2 >= 0; )
750
- b2[f2] = 0;
751
- for (f2 = 0; f2 < e2.t; ++f2)
752
- b2[f2 + c2.t] = c2.am(0, e2[f2], b2, f2, 0, c2.t);
753
- b2.s = 0, b2.clamp(), this.s != a2.s && d.ZERO.subTo(b2, b2);
754
- }
755
- function B(a2) {
756
- for (var b2 = this.abs(), c2 = a2.t = 2 * b2.t; --c2 >= 0; )
757
- a2[c2] = 0;
758
- for (c2 = 0; c2 < b2.t - 1; ++c2) {
759
- var d2 = b2.am(c2, b2[c2], a2, 2 * c2, 0, 1);
760
- (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);
761
- }
762
- a2.t > 0 && (a2[a2.t - 1] += b2.am(c2, b2[c2], a2, 2 * c2, 0, 1)), a2.s = 0, a2.clamp();
763
- }
764
- function C(a2, b2, c2) {
765
- var f2 = a2.abs();
766
- if (!(f2.t <= 0)) {
767
- var g2 = this.abs();
768
- if (g2.t < f2.t)
769
- return null != b2 && b2.fromInt(0), void (null != c2 && this.copyTo(c2));
770
- null == c2 && (c2 = e());
771
- var h2 = e(), i2 = this.s, j2 = a2.s, k2 = this.DB - t(f2[f2.t - 1]);
772
- k2 > 0 ? (f2.lShiftTo(k2, h2), g2.lShiftTo(k2, c2)) : (f2.copyTo(h2), g2.copyTo(c2));
773
- var l2 = h2.t, m2 = h2[l2 - 1];
774
- if (0 != m2) {
775
- 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;
776
- 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; )
777
- h2[h2.t++] = 0;
778
- for (; --s2 >= 0; ) {
779
- var v2 = c2[--r2] == m2 ? this.DM : Math.floor(c2[r2] * o2 + (c2[r2 - 1] + q2) * p2);
780
- if ((c2[r2] += h2.am(0, v2, c2, s2, 0, l2)) < v2)
781
- for (h2.dlShiftTo(s2, u2), c2.subTo(u2, c2); c2[r2] < --v2; )
782
- c2.subTo(u2, c2);
783
- }
784
- 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);
785
- }
786
- }
787
- }
788
- function D(a2) {
789
- var b2 = e();
790
- return this.abs().divRemTo(a2, null, b2), this.s < 0 && b2.compareTo(d.ZERO) > 0 && a2.subTo(b2, b2), b2;
791
- }
792
- function E(a2) {
793
- this.m = a2;
794
- }
795
- function F(a2) {
796
- return a2.s < 0 || a2.compareTo(this.m) >= 0 ? a2.mod(this.m) : a2;
797
- }
798
- function G(a2) {
799
- return a2;
800
- }
801
- function H(a2) {
802
- a2.divRemTo(this.m, null, a2);
803
- }
804
- function I(a2, b2, c2) {
805
- a2.multiplyTo(b2, c2), this.reduce(c2);
806
- }
807
- function J(a2, b2) {
808
- a2.squareTo(b2), this.reduce(b2);
809
- }
810
- function K() {
811
- if (this.t < 1)
812
- return 0;
813
- var a2 = this[0];
814
- if (0 == (1 & a2))
815
- return 0;
816
- var b2 = 3 & a2;
817
- 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;
818
- }
819
- function L(a2) {
820
- 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;
821
- }
822
- function M(a2) {
823
- var b2 = e();
824
- 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;
825
- }
826
- function N(a2) {
827
- var b2 = e();
828
- return a2.copyTo(b2), this.reduce(b2), b2;
829
- }
830
- function O(a2) {
831
- for (; a2.t <= this.mt2; )
832
- a2[a2.t++] = 0;
833
- for (var b2 = 0; b2 < this.m.t; ++b2) {
834
- var c2 = 32767 & a2[b2], d2 = c2 * this.mpl + ((c2 * this.mph + (a2[b2] >> 15) * this.mpl & this.um) << 15) & a2.DM;
835
- for (c2 = b2 + this.m.t, a2[c2] += this.m.am(0, d2, a2, b2, 0, this.m.t); a2[c2] >= a2.DV; )
836
- a2[c2] -= a2.DV, a2[++c2]++;
837
- }
838
- a2.clamp(), a2.drShiftTo(this.m.t, a2), a2.compareTo(this.m) >= 0 && a2.subTo(this.m, a2);
839
- }
840
- function P(a2, b2) {
841
- a2.squareTo(b2), this.reduce(b2);
842
- }
843
- function Q(a2, b2, c2) {
844
- a2.multiplyTo(b2, c2), this.reduce(c2);
845
- }
846
- function R() {
847
- return 0 == (this.t > 0 ? 1 & this[0] : this.s);
848
- }
849
- function S(a2, b2) {
850
- if (a2 > 4294967295 || 1 > a2)
851
- return d.ONE;
852
- var c2 = e(), f2 = e(), g2 = b2.convert(this), h2 = t(a2) - 1;
853
- for (g2.copyTo(c2); --h2 >= 0; )
854
- if (b2.sqrTo(c2, f2), (a2 & 1 << h2) > 0)
855
- b2.mulTo(f2, g2, c2);
856
- else {
857
- var i2 = c2;
858
- c2 = f2, f2 = i2;
859
- }
860
- return b2.revert(c2);
861
- }
862
- function T(a2, b2) {
863
- var c2;
864
- return c2 = 256 > a2 || b2.isEven() ? new E(b2) : new L(b2), this.exp(a2, c2);
865
- }
866
- function U() {
867
- this.i = 0, this.j = 0, this.S = new Array();
868
- }
869
- function V(a2) {
870
- var b2, c2, d2;
871
- for (b2 = 0; 256 > b2; ++b2)
872
- this.S[b2] = b2;
873
- for (c2 = 0, b2 = 0; 256 > b2; ++b2)
874
- c2 = c2 + this.S[b2] + a2[b2 % a2.length] & 255, d2 = this.S[b2], this.S[b2] = this.S[c2], this.S[c2] = d2;
875
- this.i = 0, this.j = 0;
876
- }
877
- function W() {
878
- var a2;
879
- 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];
880
- }
881
- function X() {
882
- return new U();
883
- }
884
- function Y(a2) {
885
- qb[rb++] ^= 255 & a2, qb[rb++] ^= a2 >> 8 & 255, qb[rb++] ^= a2 >> 16 & 255, qb[rb++] ^= a2 >> 24 & 255, rb >= sb && (rb -= sb);
886
- }
887
- function Z() {
888
- Y((/* @__PURE__ */ new Date()).getTime());
889
- }
890
- function $() {
891
- if (null == pb) {
892
- for (Z(), pb = X(), pb.init(qb), rb = 0; rb < qb.length; ++rb)
893
- qb[rb] = 0;
894
- rb = 0;
895
- }
896
- return pb.next();
897
- }
898
- function _(a2) {
899
- var b2;
900
- for (b2 = 0; b2 < a2.length; ++b2)
901
- a2[b2] = $();
902
- }
903
- function ab() {
904
- }
905
- function bb(a2, b2) {
906
- return new d(a2, b2);
907
- }
908
- function cb(a2, b2) {
909
- if (b2 < a2.length + 11)
910
- return console.error("Message too long for RSA"), null;
911
- for (var c2 = new Array(), e2 = a2.length - 1; e2 >= 0 && b2 > 0; ) {
912
- var f2 = a2.charCodeAt(e2--);
913
- 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);
914
- }
915
- c2[--b2] = 0;
916
- for (var g2 = new ab(), h2 = new Array(); b2 > 2; ) {
917
- for (h2[0] = 0; 0 == h2[0]; )
918
- g2.nextBytes(h2);
919
- c2[--b2] = h2[0];
540
+ function hexToBase64Url(hex) {
541
+ const buffer = Buffer.from(hex, "hex");
542
+ return buffer.toString("base64url");
543
+ }
544
+ var RSAKey = class {
545
+ publicKey = null;
546
+ setPublic(modulus, exponent) {
547
+ try {
548
+ const jwkKey = {
549
+ kty: "RSA",
550
+ n: hexToBase64Url(modulus),
551
+ e: hexToBase64Url(exponent)
552
+ };
553
+ this.publicKey = import_crypto.default.createPublicKey({
554
+ key: jwkKey,
555
+ format: "jwk"
556
+ });
557
+ } catch (error) {
558
+ console.error("Failed to create public key:", error);
559
+ this.publicKey = null;
920
560
  }
921
- return c2[--b2] = 2, c2[--b2] = 0, new d(c2);
922
- }
923
- function db() {
924
- this.n = null, this.e = 0, this.d = null, this.p = null, this.q = null, this.dmp1 = null, this.dmq1 = null, this.coeff = null;
925
- }
926
- function eb(a2, b2) {
927
- null != a2 && null != b2 && a2.length > 0 && b2.length > 0 ? (this.n = bb(a2, 16), this.e = parseInt(b2, 16)) : console.error("net error");
928
561
  }
929
- function fb(a2) {
930
- return a2.modPowInt(this.e, this.n);
931
- }
932
- function gb(a2) {
933
- var b2 = cb(a2, this.n.bitLength() + 7 >> 3);
934
- if (null == b2)
935
- return null;
936
- var c2 = this.doPublic(b2);
937
- if (null == c2)
562
+ encrypt(text) {
563
+ if (!this.publicKey) {
564
+ console.error("Public key not set");
938
565
  return null;
939
- var d2 = c2.toString(16);
940
- return 0 == (1 & d2.length) ? d2 : "0" + d2;
941
- }
942
- var hb, ib = 244837814094590, jb = 15715070 == (16777215 & ib);
943
- 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;
944
- var kb = 52;
945
- d.prototype.FV = Math.pow(2, kb), d.prototype.F1 = kb - hb, d.prototype.F2 = 2 * hb - kb;
946
- var lb, mb, nb = "0123456789abcdefghijklmnopqrstuvwxyz", ob = new Array();
947
- for (lb = "0".charCodeAt(0), mb = 0; 9 >= mb; ++mb)
948
- ob[lb++] = mb;
949
- for (lb = "a".charCodeAt(0), mb = 10; 36 > mb; ++mb)
950
- ob[lb++] = mb;
951
- for (lb = "A".charCodeAt(0), mb = 10; 36 > mb; ++mb)
952
- ob[lb++] = mb;
953
- 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;
954
- var pb, qb, rb, sb = 256;
955
- if (null == qb) {
956
- qb = new Array(), rb = 0;
957
- var tb;
958
- if (window.crypto && window.crypto.getRandomValues) {
959
- var ub = new Uint8Array(32);
960
- for (window.crypto.getRandomValues(ub), tb = 0; 32 > tb; ++tb)
961
- qb[rb++] = ub[tb];
962
566
  }
963
- if ("Netscape" == navigator.appName && navigator.appVersion < "5" && window.crypto) {
964
- var vb = window.crypto.random(32);
965
- for (tb = 0; tb < vb.length; ++tb)
966
- qb[rb++] = 255 & vb.charCodeAt(tb);
567
+ try {
568
+ const buffer = Buffer.from(text, "utf-8");
569
+ const encrypted = import_crypto.default.publicEncrypt(
570
+ {
571
+ key: this.publicKey,
572
+ padding: import_crypto.default.constants.RSA_PKCS1_PADDING
573
+ },
574
+ buffer
575
+ );
576
+ return encrypted.toString("hex");
577
+ } catch (error) {
578
+ console.error("RSA encryption failed:", error);
579
+ return null;
967
580
  }
968
- for (; sb > rb; )
969
- tb = Math.floor(65536 * Math.random()), qb[rb++] = tb >>> 8, qb[rb++] = 255 & tb;
970
- rb = 0, Z();
971
581
  }
972
- ab.prototype.nextBytes = _, db.prototype.doPublic = fb, db.prototype.setPublic = eb, db.prototype.encrypt = gb, c.exports = {
973
- RSAKey: db
974
- };
975
- });
976
- var rsalib_default = rsa;
582
+ };
583
+ var rsalib_default = { RSAKey };
977
584
 
978
585
  // src/utils/publicKey.ts
979
586
  var getPublicKey = async () => {
@@ -990,15 +597,29 @@ var getPublicKey = async () => {
990
597
  return { publicExponent, modulus };
991
598
  };
992
599
 
600
+ // src/utils/URLParams.ts
601
+ function URLParams($) {
602
+ const form = new URLSearchParams();
603
+ for (const [key, value] of Object.entries($)) {
604
+ form.append(key, String(value));
605
+ }
606
+ return form.toString();
607
+ }
608
+
993
609
  // src/modules/login_np.ts
994
- var RSAKey = rsalib_default.RSAKey;
610
+ var RSAKey2 = rsalib_default.RSAKey;
995
611
  function randomString() {
996
612
  const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
997
613
  return random.toLowerCase();
998
614
  }
999
615
  var loginNP = {
616
+ /**
617
+ * 账号密码登录
618
+ * @param username 用户名
619
+ * @param password 密码
620
+ * @returns 登录成功后的 pacmtoken
621
+ */
1000
622
  async authn(username, password) {
1001
- var error = "";
1002
623
  var $ = {
1003
624
  "isAsync": true,
1004
625
  "enpassword": "",
@@ -1014,22 +635,18 @@ var loginNP = {
1014
635
  const p = await getPublicKey();
1015
636
  const { publicExponent, modulus } = p || {};
1016
637
  if (!modulus || !publicExponent) {
1017
- error = "\u83B7\u53D6\u516C\u94A5\u5931\u8D25";
1018
- return { error };
638
+ return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
1019
639
  }
1020
- var rsa2 = new RSAKey();
1021
- rsa2.setPublic(modulus, publicExponent);
1022
- const rsa_pwd = rsa2.encrypt(password);
1023
- const rsa_username = rsa2.encrypt(username);
640
+ var rsa = new RSAKey2();
641
+ rsa.setPublic(modulus, publicExponent);
642
+ const rsa_pwd = rsa.encrypt(password);
643
+ const rsa_username = rsa.encrypt(username);
1024
644
  const fakeFingerprint = randomString();
1025
645
  $.fingerPrint = fakeFingerprint;
1026
646
  $.fingerPrintDetail = fakeFingerprint;
1027
- $.enpassword = rsa_pwd;
1028
- $.loginID = rsa_username;
1029
- const form = new URLSearchParams();
1030
- for (const [key, value] of Object.entries($)) {
1031
- form.append(key, String(value));
1032
- }
647
+ $.enpassword = rsa_pwd || "";
648
+ $.loginID = rsa_username || "";
649
+ const form = URLParams($);
1033
650
  const res = await fetch(
1034
651
  `https://passport.migu.cn/authn`,
1035
652
  {
@@ -1040,7 +657,7 @@ var loginNP = {
1040
657
  body: form
1041
658
  }
1042
659
  );
1043
- if (!res.ok) return { error: ["\u8BF7\u6C42\u767B\u5F55\u5931\u8D25"] };
660
+ if (!res.ok) return { error: "\u8BF7\u6C42\u767B\u5F55\u5931\u8D25" };
1044
661
  const body = await res.json();
1045
662
  return body;
1046
663
  }
@@ -1184,7 +801,7 @@ var getTodayRecommend = async (pacmtoken) => {
1184
801
  };
1185
802
 
1186
803
  // src/modules/login_sim.ts
1187
- var RSAKey2 = rsalib_default.RSAKey;
804
+ var RSAKey3 = rsalib_default.RSAKey;
1188
805
  function randomString2() {
1189
806
  const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
1190
807
  return random.toLowerCase();
@@ -1207,17 +824,14 @@ var loginSim = {
1207
824
  if (!modulus || !publicExponent) {
1208
825
  return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
1209
826
  }
1210
- const rsa2 = new RSAKey2();
1211
- rsa2.setPublic(modulus, publicExponent);
1212
- const encPhone = rsa2.encrypt(phone);
827
+ const rsa = new RSAKey3();
828
+ rsa.setPublic(modulus, publicExponent);
829
+ const encPhone = rsa.encrypt(phone);
1213
830
  const fakeFingerprint = randomString2();
1214
831
  $.fingerPrint = fakeFingerprint;
1215
832
  $.fingerPrintDetail = fakeFingerprint;
1216
- $.encMsisdn = encPhone;
1217
- const form = new URLSearchParams();
1218
- for (const [key, value] of Object.entries($)) {
1219
- form.append(key, String(value));
1220
- }
833
+ $.encMsisdn = encPhone || "";
834
+ const form = URLParams($);
1221
835
  const send = await fetch(
1222
836
  `https://passport.migu.cn/api/simauth/send`,
1223
837
  {
@@ -1322,12 +936,204 @@ var getSimilarSongRecommend = async (contentId = "") => {
1322
936
  );
1323
937
  };
1324
938
 
939
+ // src/modules/login_oneclick.ts
940
+ var import_crypto2 = __toESM(require("crypto"), 1);
941
+ var nav = {
942
+ "platform": "iPhone",
943
+ "userAgent": "Mozilla/5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.1",
944
+ "appVersion": "5.0 (iPhone; CPU iPhone OS 17_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Mobile/15E148 Safari/604.1",
945
+ "cookieEnabled": true,
946
+ "empty": null,
947
+ "hardwareConcurrency": 6,
948
+ "language": "zh-CN",
949
+ "plugins": "",
950
+ "availWidth": 390,
951
+ "availHeight": 844,
952
+ "colorDepth": 24,
953
+ "timezoneOffset": -480
954
+ };
955
+ var YDRZ = {
956
+ "optparams": {
957
+ "uuid": "",
958
+ "msgId": "",
959
+ "traceId": "",
960
+ "businessType": "10",
961
+ "appId": "",
962
+ "timestamp": yTime(),
963
+ "isimge": false,
964
+ "expandParams": "",
965
+ "userInformations": "",
966
+ "CMRequestApi": ""
967
+ },
968
+ randomString(len, range = 32) {
969
+ var i, bite = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""), list = [];
970
+ for (i = 0; i < len; i++)
971
+ list[i] = bite[0 | Math.random() * range];
972
+ return list.join("");
973
+ },
974
+ randomRange(min, max) {
975
+ return Math.floor(Math.random() * (min - max) + max);
976
+ },
977
+ getUA() {
978
+ const ua = nav.userAgent, l = [
979
+ nav.platform,
980
+ ua,
981
+ nav.appVersion,
982
+ nav.cookieEnabled,
983
+ void 0,
984
+ nav.hardwareConcurrency,
985
+ nav.language,
986
+ nav.plugins,
987
+ nav.availWidth,
988
+ nav.availHeight,
989
+ nav.colorDepth,
990
+ nav.timezoneOffset
991
+ ], key = l.join("@@"), finalUA = ua.length > 100 ? ua.substring(0, 100) : ua;
992
+ return nav.platform + "@@" + finalUA + "@@" + md5(key);
993
+ },
994
+ uaE(str) {
995
+ var b, c, d, r4, r1, r2, r3, result = "", bite = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", i = 0;
996
+ for (; i < str.length; )
997
+ r4 = (b = str.charCodeAt(i++)) >> 2, r1 = (3 & b) << 4 | (c = str.charCodeAt(i++)) >> 4, r2 = (15 & c) << 2 | (d = str.charCodeAt(i++)) >> 6, r3 = 63 & d, isNaN(c) ? r2 = r3 = 64 : isNaN(d) && (r3 = 64), result = result + bite.charAt(r4) + bite.charAt(r1) + bite.charAt(r2) + bite.charAt(r3);
998
+ return result;
999
+ },
1000
+ getUserInfo() {
1001
+ return encodeURIComponent(this.uaE(this.getUA()));
1002
+ },
1003
+ getSign(appID, version) {
1004
+ const optparams = this.optparams;
1005
+ optparams.uuid = this.randomString(32, 32);
1006
+ optparams.msgId = this.randomString(32, 32);
1007
+ this.optparams = optparams;
1008
+ return appID + optparams.msgId + optparams.timestamp + optparams.uuid + version;
1009
+ },
1010
+ async getTokenInfo(data) {
1011
+ const optparams = this.optparams;
1012
+ const requestData = {
1013
+ "version": data.version,
1014
+ "appId": data.appId,
1015
+ "openType": data.openType,
1016
+ "expandParams": data.expandParams,
1017
+ "isTest": data.isTest,
1018
+ "sign": data.sign,
1019
+ "getNetworkType": data.getNetworkType,
1020
+ "getMsisdnMask": data.getMsisdnMask,
1021
+ "traceId": optparams.uuid,
1022
+ "msgId": optparams.msgId,
1023
+ "timestamp": optparams.timestamp,
1024
+ "uuid": optparams.uuid,
1025
+ "businessType": optparams.businessType,
1026
+ "userInformations": this.getUserInfo()
1027
+ };
1028
+ const res = await fetch(
1029
+ "https://verify.cmpassport.com/h5/getPreMobile",
1030
+ {
1031
+ method: "POST",
1032
+ headers: {
1033
+ "Referer": "https://passport.migu.cn/",
1034
+ "Origin": "https://passport.migu.cn"
1035
+ },
1036
+ body: JSON.stringify(requestData)
1037
+ }
1038
+ );
1039
+ if (!res.ok) return;
1040
+ const json = await res.json(), token = json.body?.token || "";
1041
+ if (!token) return;
1042
+ return token;
1043
+ }
1044
+ };
1045
+ function yTime() {
1046
+ const date = /* @__PURE__ */ new Date(), a = [
1047
+ date.getFullYear(),
1048
+ date.getMonth() + 1,
1049
+ date.getDate(),
1050
+ date.getHours(),
1051
+ date.getMinutes(),
1052
+ date.getSeconds(),
1053
+ date.getMilliseconds()
1054
+ ];
1055
+ const f = a.map((t) => {
1056
+ return t.toString().padStart(2, "0");
1057
+ });
1058
+ f[6] = f[6].toString().padStart(3, "0");
1059
+ return f.join("");
1060
+ }
1061
+ function md5(s) {
1062
+ return import_crypto2.default.createHash("md5").update(s, "utf-8").digest("hex");
1063
+ }
1064
+ var genInternetSign = async () => {
1065
+ const time = yTime(), e = time, c = "220029", msgId = getDeviceId(), d = msgId;
1066
+ const preSign = YDRZ.getSign("300012033963", "1.2"), b = preSign;
1067
+ let key = "interfacename=genInternetSign&sourceid=" + c + "&systemtime=" + e + "&msgid=" + d + "&preSign=" + b;
1068
+ key = encodeURIComponent(key);
1069
+ const signature = md5(key);
1070
+ const url = `https://passport.migu.cn/api/genInternetSign?preSign=${preSign}&msgid=${msgId}&systemtime=${time}&sourceid=220029&signature=${signature}`;
1071
+ const res = await fetch(url);
1072
+ if (!res.ok) return void 0;
1073
+ const data = await res.json();
1074
+ if (!data || data.status !== 2e3) return void 0;
1075
+ const rsaSign = data.result?.rsaSign || "";
1076
+ return rsaSign;
1077
+ };
1078
+ var getSTToken = async (uniToken) => {
1079
+ const $ = {
1080
+ "sourceID": "220029",
1081
+ "appType": 0,
1082
+ "relayState": "",
1083
+ "token": uniToken,
1084
+ "userInformation": YDRZ.getUserInfo(),
1085
+ "isFirst": 1
1086
+ };
1087
+ const form = URLParams($);
1088
+ const res = await fetch(
1089
+ "https://passport.migu.cn/authn/uniTokenValidate",
1090
+ {
1091
+ method: "POST",
1092
+ headers: {
1093
+ "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
1094
+ },
1095
+ body: form
1096
+ }
1097
+ );
1098
+ if (!res.ok) return { error: "fetch uni e" };
1099
+ const json = await res.json(), status = json.status?.toString() || "", token = json.result?.token || "", msisdn = json.result?.msisdn || "";
1100
+ if (status !== "2000") return { error: "status e" };
1101
+ return { token, msisdn, status };
1102
+ };
1103
+ var authn = async () => {
1104
+ const rsaSign = await genInternetSign();
1105
+ if (!rsaSign) return { error: "genInternetSign failed" };
1106
+ const uniToken = await YDRZ.getTokenInfo({
1107
+ version: "1.2",
1108
+ appId: "300012033963",
1109
+ sign: rsaSign,
1110
+ openType: "1",
1111
+ expandParams: "",
1112
+ isTest: false,
1113
+ getNetworkType: "",
1114
+ getMsisdnMask: ""
1115
+ });
1116
+ if (!uniToken) return { error: "getTokenInfo failed" };
1117
+ const result = await getSTToken(uniToken);
1118
+ if ("error" in result) return result;
1119
+ const { token, msisdn, status } = result;
1120
+ if (!token) return { error: "no token" };
1121
+ if (!msisdn) return { error: "no msisdn" };
1122
+ return { token, msisdn, status };
1123
+ };
1124
+ var loginOneClick = {
1125
+ genInternetSign,
1126
+ getSTToken,
1127
+ authn
1128
+ };
1129
+
1325
1130
  // src/index.ts
1326
1131
  function createClient() {
1327
1132
  return modules_exports;
1328
1133
  }
1329
1134
  // Annotate the CommonJS export names for ESM import in node:
1330
1135
  0 && (module.exports = {
1136
+ YDRZ,
1331
1137
  checkCanListen,
1332
1138
  checkToken,
1333
1139
  createClient,
@@ -1366,6 +1172,7 @@ function createClient() {
1366
1172
  getUserMyList,
1367
1173
  getVersion,
1368
1174
  loginNP,
1175
+ loginOneClick,
1369
1176
  loginSim,
1370
1177
  modules,
1371
1178
  queryUserInfo,