migu-api-enhanced 1.2.5 → 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.js CHANGED
@@ -455,438 +455,52 @@ var getMvHls = async (mvContentId, mvCopyrightId, url, size, format = "050012",
455
455
  );
456
456
  };
457
457
 
458
- // src/utils/rsalib.js
458
+ // src/utils/rsalib.ts
459
459
  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];
460
+ function hexToBase64Url(hex) {
461
+ const buffer = Buffer.from(hex, "hex");
462
+ return buffer.toString("base64url");
463
+ }
464
+ var RSAKey = class {
465
+ publicKey = null;
466
+ setPublic(modulus, exponent) {
467
+ try {
468
+ const jwkKey = {
469
+ kty: "RSA",
470
+ n: hexToBase64Url(modulus),
471
+ e: hexToBase64Url(exponent)
472
+ };
473
+ this.publicKey = crypto.createPublicKey({
474
+ key: jwkKey,
475
+ format: "jwk"
476
+ });
477
+ } catch (error) {
478
+ console.error("Failed to create public key:", error);
479
+ this.publicKey = null;
833
480
  }
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
481
  }
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)
482
+ encrypt(text) {
483
+ if (!this.publicKey) {
484
+ console.error("Public key not set");
851
485
  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
486
  }
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);
487
+ try {
488
+ const buffer = Buffer.from(text, "utf-8");
489
+ const encrypted = crypto.publicEncrypt(
490
+ {
491
+ key: this.publicKey,
492
+ padding: crypto.constants.RSA_PKCS1_PADDING
493
+ },
494
+ buffer
495
+ );
496
+ return encrypted.toString("hex");
497
+ } catch (error) {
498
+ console.error("RSA encryption failed:", error);
499
+ return null;
880
500
  }
881
- for (; sb > rb; )
882
- tb = Math.floor(65536 * Math.random()), qb[rb++] = tb >>> 8, qb[rb++] = 255 & tb;
883
- rb = 0, Z();
884
501
  }
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;
502
+ };
503
+ var rsalib_default = { RSAKey };
890
504
 
891
505
  // src/utils/publicKey.ts
892
506
  var getPublicKey = async () => {
@@ -913,7 +527,7 @@ function URLParams($) {
913
527
  }
914
528
 
915
529
  // src/modules/login_np.ts
916
- var RSAKey = rsalib_default.RSAKey;
530
+ var RSAKey2 = 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,15 +557,15 @@ 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 RSAKey2();
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`,
@@ -1107,7 +721,7 @@ var getTodayRecommend = async (pacmtoken) => {
1107
721
  };
1108
722
 
1109
723
  // src/modules/login_sim.ts
1110
- var RSAKey2 = rsalib_default.RSAKey;
724
+ var RSAKey3 = rsalib_default.RSAKey;
1111
725
  function randomString2() {
1112
726
  const random = Array.from({ length: 32 }, () => Math.floor(Math.random() * 16).toString(16)).join("");
1113
727
  return random.toLowerCase();
@@ -1130,13 +744,13 @@ var loginSim = {
1130
744
  if (!modulus || !publicExponent) {
1131
745
  return { error: "\u83B7\u53D6\u516C\u94A5\u5931\u8D25" };
1132
746
  }
1133
- const rsa2 = new RSAKey2();
1134
- rsa2.setPublic(modulus, publicExponent);
1135
- const encPhone = rsa2.encrypt(phone);
747
+ const rsa = new RSAKey3();
748
+ rsa.setPublic(modulus, publicExponent);
749
+ const encPhone = rsa.encrypt(phone);
1136
750
  const fakeFingerprint = randomString2();
1137
751
  $.fingerPrint = fakeFingerprint;
1138
752
  $.fingerPrintDetail = fakeFingerprint;
1139
- $.encMsisdn = encPhone;
753
+ $.encMsisdn = encPhone || "";
1140
754
  const form = URLParams($);
1141
755
  const send = await fetch(
1142
756
  `https://passport.migu.cn/api/simauth/send`,