Files
shuidrop_gui/static/js/encode_message.js

1766 lines
62 KiB
JavaScript
Raw Normal View History

2025-09-12 20:42:00 +08:00
window = globalThis;;
var CryptoJS = CryptoJS || (function (Math, undefined) {
var C = {};
var C_lib = C.lib = {};
var Base = C_lib.Base = (function () {
function F() {};
return {
extend: function (overrides) {
F.prototype = this;
var subtype = new F();
if (overrides) {
subtype.mixIn(overrides);
}
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
subtype.init = function () {
subtype.$super.init.apply(this, arguments);
};
}
subtype.init.prototype = subtype;
subtype.$super = this;
return subtype;
}, create: function () {
var instance = this.extend();
instance.init.apply(instance, arguments);
return instance;
}, init: function () {}, mixIn: function (properties) {
for (var propertyName in properties) {
if (properties.hasOwnProperty(propertyName)) {
this[propertyName] = properties[propertyName];
}
}
if (properties.hasOwnProperty('toString')) {
this.toString = properties.toString;
}
}, clone: function () {
return this.init.prototype.extend(this);
}
};
}());
var WordArray = C_lib.WordArray = Base.extend({
init: function (words, sigBytes) {
words = this.words = words || [];
if (sigBytes != undefined) {
this.sigBytes = sigBytes;
} else {
this.sigBytes = words.length * 4;
}
}, toString: function (encoder) {
return (encoder || Hex).stringify(this);
}, concat: function (wordArray) {
var thisWords = this.words;
var thatWords = wordArray.words;
var thisSigBytes = this.sigBytes;
var thatSigBytes = wordArray.sigBytes;
this.clamp();
if (thisSigBytes % 4) {
for (var i = 0; i < thatSigBytes; i++) {
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
}
} else if (thatWords.length > 0xffff) {
for (var i = 0; i < thatSigBytes; i += 4) {
thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
}
} else {
thisWords.push.apply(thisWords, thatWords);
}
this.sigBytes += thatSigBytes;
return this;
}, clamp: function () {
var words = this.words;
var sigBytes = this.sigBytes;
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
words.length = Math.ceil(sigBytes / 4);
}, clone: function () {
var clone = Base.clone.call(this);
clone.words = this.words.slice(0);
return clone;
}, random: function (nBytes) {
var words = [];
var r = (function (m_w) {
var m_w = m_w;
var m_z = 0x3ade68b1;
var mask = 0xffffffff;
return function () {
m_z = (0x9069 * (m_z & 0xFFFF) + (m_z >> 0x10)) & mask;
m_w = (0x4650 * (m_w & 0xFFFF) + (m_w >> 0x10)) & mask;
var result = ((m_z << 0x10) + m_w) & mask;
result /= 0x100000000;
result += 0.5;
return result * (Math.random() > .5 ? 1 : -1);
}
});
for (var i = 0, rcache; i < nBytes; i += 4) {
var _r = r((rcache || Math.random()) * 0x100000000);
rcache = _r() * 0x3ade67b7;
words.push((_r() * 0x100000000) | 0);
}
return new WordArray.init(words, nBytes);
}
});
var C_enc = C.enc = {};
var Hex = C_enc.Hex = {
stringify: function (wordArray) {
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
var hexChars = [];
for (var i = 0; i < sigBytes; i++) {
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
hexChars.push((bite >>> 4).toString(16));
hexChars.push((bite & 0x0f).toString(16));
}
return hexChars.join('');
}, parse: function (hexStr) {
var hexStrLength = hexStr.length;
var words = [];
for (var i = 0; i < hexStrLength; i += 2) {
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
}
return new WordArray.init(words, hexStrLength / 2);
}
};
var Latin1 = C_enc.Latin1 = {
stringify: function (wordArray) {
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
var latin1Chars = [];
for (var i = 0; i < sigBytes; i++) {
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
latin1Chars.push(String.fromCharCode(bite));
}
return latin1Chars.join('');
}, parse: function (latin1Str) {
var latin1StrLength = latin1Str.length;
var words = [];
for (var i = 0; i < latin1StrLength; i++) {
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
}
return new WordArray.init(words, latin1StrLength);
}
};
var Utf8 = C_enc.Utf8 = {
stringify: function (wordArray) {
try {
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
} catch (e) {
throw new Error('Malformed UTF-8 data');
}
}, parse: function (utf8Str) {
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
}
};
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
reset: function () {
this._data = new WordArray.init();
this._nDataBytes = 0;
}, _append: function (data) {
if (typeof data == 'string') {
data = Utf8.parse(data);
}
this._data.concat(data);
this._nDataBytes += data.sigBytes;
}, _process: function (doFlush) {
var data = this._data;
var dataWords = data.words;
var dataSigBytes = data.sigBytes;
var blockSize = this.blockSize;
var blockSizeBytes = blockSize * 4;
var nBlocksReady = dataSigBytes / blockSizeBytes;
if (doFlush) {
nBlocksReady = Math.ceil(nBlocksReady);
} else {
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
}
var nWordsReady = nBlocksReady * blockSize;
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
if (nWordsReady) {
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
this._doProcessBlock(dataWords, offset);
}
var processedWords = dataWords.splice(0, nWordsReady);
data.sigBytes -= nBytesReady;
}
return new WordArray.init(processedWords, nBytesReady);
}, clone: function () {
var clone = Base.clone.call(this);
clone._data = this._data.clone();
return clone;
}, _minBufferSize: 0
});
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
cfg: Base.extend(),
init: function (cfg) {
this.cfg = this.cfg.extend(cfg);
this.reset();
}, reset: function () {
BufferedBlockAlgorithm.reset.call(this);
this._doReset();
}, update: function (messageUpdate) {
this._append(messageUpdate);
this._process();
return this;
}, finalize: function (messageUpdate) {
if (messageUpdate) {
this._append(messageUpdate);
}
var hash = this._doFinalize();
return hash;
}, blockSize: 512 / 32,
_createHelper: function (hasher) {
return function (message, cfg) {
return new hasher.init(cfg).finalize(message);
};
}, _createHmacHelper: function (hasher) {
return function (message, key) {
return new C_algo.HMAC.init(hasher, key).finalize(message);
};
}
});
var C_algo = C.algo = {};
return C;
}(Math));
(function () {
var C = CryptoJS;
var C_lib = C.lib;
var WordArray = C_lib.WordArray;
var C_enc = C.enc;
var Base64 = C_enc.Base64 = {
stringify: function (wordArray) {
var words = wordArray.words;
var sigBytes = wordArray.sigBytes;
var map = this._map;
wordArray.clamp();
var base64Chars = [];
for (var i = 0; i < sigBytes; i += 3) {
var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
for (var j = 0;
(j < 4) && (i + j * 0.75 < sigBytes); j++) {
base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
}
}
var paddingChar = map.charAt(64);
if (paddingChar) {
while (base64Chars.length % 4) {
base64Chars.push(paddingChar);
}
}
return base64Chars.join('');
}, parse: function (base64Str) {
var base64StrLength = base64Str.length;
var map = this._map;
var reverseMap = this._reverseMap;
if (!reverseMap) {
reverseMap = this._reverseMap = [];
for (var j = 0; j < map.length; j++) {
reverseMap[map.charCodeAt(j)] = j;
}
}
var paddingChar = map.charAt(64);
if (paddingChar) {
var paddingIndex = base64Str.indexOf(paddingChar);
if (paddingIndex !== -1) {
base64StrLength = paddingIndex;
}
}
return parseLoop(base64Str, base64StrLength, reverseMap);
}, _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
};
function parseLoop(base64Str, base64StrLength, reverseMap) {
var words = [];
var nBytes = 0;
for (var i = 0; i < base64StrLength; i++) {
if (i % 4) {
var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
nBytes++;
}
}
return WordArray.create(words, nBytes);
}
}());
function B64_Encrypt(word) {
var src = CryptoJS.enc.Utf8.parse(word);
return CryptoJS.enc.Base64.stringify(src);
}
function B64_Decrypt(word) {
var src = CryptoJS.enc.Base64.parse(word);
return CryptoJS.enc.Utf8.stringify(src);
}
!function(b) {
var r, u, t, n;
r = {
1: [function(t, e) {
e.exports = function(t, e) {
for (var n = Array(arguments.length - 1), r = 0, o = 2, i = !0; o < arguments.length; )
n[r++] = arguments[o++];
return new Promise((function(o, a) {
n[r] = function(t) {
if (i)
if (i = !1,
t)
a(t);
else {
for (var e = Array(arguments.length - 1), n = 0; n < e.length; )
e[n++] = arguments[n];
o.apply(null, e)
}
}
;
try {
t.apply(e || null, n)
} catch (t) {
i && (i = !1,
a(t))
}
}
))
}
}
, {}],
2: [function(t, e, n) {
var r = n;
r.length = function(t) {
var e = t.length;
if (!e)
return 0;
for (var n = 0; 1 < --e % 4 && "=" === t.charAt(e); )
++n;
return Math.ceil(3 * t.length) / 4 - n
}
;
for (var o = Array(64), i = Array(123), a = 0; a < 64; )
i[o[a] = a < 26 ? a + 65 : a < 52 ? a + 71 : a < 62 ? a - 4 : a - 59 | 43] = a++;
r.encode = function(t, e, n) {
for (var r, i = null, a = [], s = 0, u = 0; e < n; ) {
var c = t[e++];
switch (u) {
case 0:
a[s++] = o[c >> 2],
r = (3 & c) << 4,
u = 1;
break;
case 1:
a[s++] = o[r | c >> 4],
r = (15 & c) << 2,
u = 2;
break;
case 2:
a[s++] = o[r | c >> 6],
a[s++] = o[63 & c],
u = 0
}
8191 < s && ((i || (i = [])).push(String.fromCharCode.apply(String, a)),
s = 0)
}
return u && (a[s++] = o[r],
a[s++] = 61,
1 === u && (a[s++] = 61)),
i ? (s && i.push(String.fromCharCode.apply(String, a.slice(0, s))),
i.join("")) : String.fromCharCode.apply(String, a.slice(0, s))
}
;
var s = "invalid encoding";
r.decode = function(t, e, n) {
for (var r, o = n, a = 0, u = 0; u < t.length; ) {
var c = t.charCodeAt(u++);
if (61 === c && 1 < a)
break;
if ((c = i[c]) === b)
throw Error(s);
switch (a) {
case 0:
r = c,
a = 1;
break;
case 1:
e[n++] = r << 2 | (48 & c) >> 4,
r = c,
a = 2;
break;
case 2:
e[n++] = (15 & r) << 4 | (60 & c) >> 2,
r = c,
a = 3;
break;
case 3:
e[n++] = (3 & r) << 6 | c,
a = 0
}
}
if (1 === a)
throw Error(s);
return n - o
}
,
r.test = function(t) {
return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)
}
}
, {}],
3: [function(t, e) {
function n() {
this.t = {}
}
(e.exports = n).prototype.on = function(t, e, n) {
return (this.t[t] || (this.t[t] = [])).push({
fn: e,
ctx: n || this
}),
this
}
,
n.prototype.off = function(t, e) {
if (t === b)
this.t = {};
else if (e === b)
this.t[t] = [];
else
for (var n = this.t[t], r = 0; r < n.length; )
n[r].fn === e ? n.splice(r, 1) : ++r;
return this
}
,
n.prototype.emit = function(t) {
var e = this.t[t];
if (e) {
for (var n = [], r = 1; r < arguments.length; )
n.push(arguments[r++]);
for (r = 0; r < e.length; )
e[r].fn.apply(e[r++].ctx, n)
}
return this
}
}
, {}],
4: [function(t, e) {
function n(t) {
return "undefined" != typeof Float32Array ? function() {
var e = new Float32Array([-0])
, n = new Uint8Array(e.buffer)
, r = 128 === n[3];
function o(t, r, o) {
e[0] = t,
r[o] = n[0],
r[o + 1] = n[1],
r[o + 2] = n[2],
r[o + 3] = n[3]
}
function i(t, r, o) {
e[0] = t,
r[o] = n[3],
r[o + 1] = n[2],
r[o + 2] = n[1],
r[o + 3] = n[0]
}
function a(t, r) {
return n[0] = t[r],
n[1] = t[r + 1],
n[2] = t[r + 2],
n[3] = t[r + 3],
e[0]
}
function s(t, r) {
return n[3] = t[r],
n[2] = t[r + 1],
n[1] = t[r + 2],
n[0] = t[r + 3],
e[0]
}
t.writeFloatLE = r ? o : i,
t.writeFloatBE = r ? i : o,
t.readFloatLE = r ? a : s,
t.readFloatBE = r ? s : a
}() : function() {
function e(t, e, n, r) {
var o = e < 0 ? 1 : 0;
if (o && (e = -e),
0 === e)
t(0 < 1 / e ? 0 : 2147483648, n, r);
else if (isNaN(e))
t(2143289344, n, r);
else if (34028234663852886e22 < e)
t((o << 31 | 2139095040) >>> 0, n, r);
else if (e < 11754943508222875e-54)
t((o << 31 | Math.round(e / 1401298464324817e-60)) >>> 0, n, r);
else {
var i = Math.floor(Math.log(e) / Math.LN2);
t((o << 31 | i + 127 << 23 | 8388607 & Math.round(e * Math.pow(2, -i) * 8388608)) >>> 0, n, r)
}
}
function n(t, e, n) {
var r = t(e, n)
, o = 2 * (r >> 31) + 1
, i = r >>> 23 & 255
, a = 8388607 & r;
return 255 === i ? a ? NaN : o * (1 / 0) : 0 === i ? 1401298464324817e-60 * o * a : o * Math.pow(2, i - 150) * (a + 8388608)
}
t.writeFloatLE = e.bind(null, r),
t.writeFloatBE = e.bind(null, o),
t.readFloatLE = n.bind(null, i),
t.readFloatBE = n.bind(null, a)
}(),
"undefined" != typeof Float64Array ? function() {
var e = new Float64Array([-0])
, n = new Uint8Array(e.buffer)
, r = 128 === n[7];
function o(t, r, o) {
e[0] = t,
r[o] = n[0],
r[o + 1] = n[1],
r[o + 2] = n[2],
r[o + 3] = n[3],
r[o + 4] = n[4],
r[o + 5] = n[5],
r[o + 6] = n[6],
r[o + 7] = n[7]
}
function i(t, r, o) {
e[0] = t,
r[o] = n[7],
r[o + 1] = n[6],
r[o + 2] = n[5],
r[o + 3] = n[4],
r[o + 4] = n[3],
r[o + 5] = n[2],
r[o + 6] = n[1],
r[o + 7] = n[0]
}
function a(t, r) {
return n[0] = t[r],
n[1] = t[r + 1],
n[2] = t[r + 2],
n[3] = t[r + 3],
n[4] = t[r + 4],
n[5] = t[r + 5],
n[6] = t[r + 6],
n[7] = t[r + 7],
e[0]
}
function s(t, r) {
return n[7] = t[r],
n[6] = t[r + 1],
n[5] = t[r + 2],
n[4] = t[r + 3],
n[3] = t[r + 4],
n[2] = t[r + 5],
n[1] = t[r + 6],
n[0] = t[r + 7],
e[0]
}
t.writeDoubleLE = r ? o : i,
t.writeDoubleBE = r ? i : o,
t.readDoubleLE = r ? a : s,
t.readDoubleBE = r ? s : a
}() : function() {
function e(t, e, n, r, o, i) {
var a = r < 0 ? 1 : 0;
if (a && (r = -r),
0 === r)
t(0, o, i + e),
t(0 < 1 / r ? 0 : 2147483648, o, i + n);
else if (isNaN(r))
t(0, o, i + e),
t(2146959360, o, i + n);
else if (17976931348623157e292 < r)
t(0, o, i + e),
t((a << 31 | 2146435072) >>> 0, o, i + n);
else {
var s;
if (r < 22250738585072014e-324)
t((s = r / 5e-324) >>> 0, o, i + e),
t((a << 31 | s / 4294967296) >>> 0, o, i + n);
else {
var u = Math.floor(Math.log(r) / Math.LN2);
1024 === u && (u = 1023),
t(4503599627370496 * (s = r * Math.pow(2, -u)) >>> 0, o, i + e),
t((a << 31 | u + 1023 << 20 | 1048576 * s & 1048575) >>> 0, o, i + n)
}
}
}
function n(t, e, n, r, o) {
var i = t(r, o + e)
, a = t(r, o + n)
, s = 2 * (a >> 31) + 1
, u = a >>> 20 & 2047
, c = 4294967296 * (1048575 & a) + i;
return 2047 === u ? c ? NaN : s * (1 / 0) : 0 === u ? 5e-324 * s * c : s * Math.pow(2, u - 1075) * (c + 4503599627370496)
}
t.writeDoubleLE = e.bind(null, r, 0, 4),
t.writeDoubleBE = e.bind(null, o, 4, 0),
t.readDoubleLE = n.bind(null, i, 0, 4),
t.readDoubleBE = n.bind(null, a, 4, 0)
}(),
t
}
function r(t, e, n) {
e[n] = 255 & t,
e[n + 1] = t >>> 8 & 255,
e[n + 2] = t >>> 16 & 255,
e[n + 3] = t >>> 24
}
function o(t, e, n) {
e[n] = t >>> 24,
e[n + 1] = t >>> 16 & 255,
e[n + 2] = t >>> 8 & 255,
e[n + 3] = 255 & t
}
function i(t, e) {
return (t[e] | t[e + 1] << 8 | t[e + 2] << 16 | t[e + 3] << 24) >>> 0
}
function a(t, e) {
return (t[e] << 24 | t[e + 1] << 16 | t[e + 2] << 8 | t[e + 3]) >>> 0
}
e.exports = n(n)
}
, {}],
5: [function(t, n, i) {
function r(t) {
try {
var n = eval("require")(t);
if (n && (n.length || Object.keys(n).length))
return n
} catch (t) {}
return null
}
n.exports = r
}
, {}],
6: [function(t, e) {
e.exports = function(t, e, n) {
var r = n || 8192
, o = r >>> 1
, i = null
, a = r;
return function(n) {
if (n < 1 || o < n)
return t(n);
r < a + n && (i = t(r),
a = 0);
var s = e.call(i, a, a += n);
return 7 & a && (a = 1 + (7 | a)),
s
}
}
}
, {}],
7: [function(t, e, n) {
var r = n;
r.length = function(t) {
for (var e = 0, n = 0, r = 0; r < t.length; ++r)
(n = t.charCodeAt(r)) < 128 ? e += 1 : n < 2048 ? e += 2 : 55296 == (64512 & n) && 56320 == (64512 & t.charCodeAt(r + 1)) ? (++r,
e += 4) : e += 3;
return e
}
,
r.read = function(t, e, n) {
if (n - e < 1)
return "";
for (var r, o = null, i = [], a = 0; e < n; )
(r = t[e++]) < 128 ? i[a++] = r : 191 < r && r < 224 ? i[a++] = (31 & r) << 6 | 63 & t[e++] : 239 < r && r < 365 ? (r = ((7 & r) << 18 | (63 & t[e++]) << 12 | (63 & t[e++]) << 6 | 63 & t[e++]) - 65536,
i[a++] = 55296 + (r >> 10),
i[a++] = 56320 + (1023 & r)) : i[a++] = (15 & r) << 12 | (63 & t[e++]) << 6 | 63 & t[e++],
8191 < a && ((o || (o = [])).push(String.fromCharCode.apply(String, i)),
a = 0);
return o ? (a && o.push(String.fromCharCode.apply(String, i.slice(0, a))),
o.join("")) : String.fromCharCode.apply(String, i.slice(0, a))
}
,
r.write = function(t, e, n) {
for (var r, o, i = n, a = 0; a < t.length; ++a)
(r = t.charCodeAt(a)) < 128 ? e[n++] = r : (r < 2048 ? e[n++] = r >> 6 | 192 : (55296 == (64512 & r) && 56320 == (64512 & (o = t.charCodeAt(a + 1))) ? (r = 65536 + ((1023 & r) << 10) + (1023 & o),
++a,
e[n++] = r >> 18 | 240,
e[n++] = r >> 12 & 63 | 128) : e[n++] = r >> 12 | 224,
e[n++] = r >> 6 & 63 | 128),
e[n++] = 63 & r | 128);
return n - i
}
}
, {}],
8: [function(t, e, n) {
var r = n;
function o() {
r.Reader.n(r.BufferReader),
r.util.n()
}
r.build = "minimal",
r.Writer = t(16),
r.BufferWriter = t(17),
r.Reader = t(9),
r.BufferReader = t(10),
r.util = t(15),
r.rpc = t(12),
r.roots = t(11),
r.configure = o,
r.Writer.n(r.BufferWriter),
o()
}
, {
10: 10,
11: 11,
12: 12,
15: 15,
16: 16,
17: 17,
9: 9
}],
9: [function(t, e) {
e.exports = s;
var n, r = t(15), o = r.LongBits, i = r.utf8;
function a(t, e) {
return RangeError("index out of range: " + t.pos + " + " + (e || 1) + " > " + t.len)
}
function s(t) {
this.buf = t,
this.pos = 0,
this.len = t.length
}
var u, c = "undefined" != typeof Uint8Array ? function(t) {
if (t instanceof Uint8Array || Array.isArray(t))
return new s(t);
throw Error("illegal buffer")
}
: function(t) {
if (Array.isArray(t))
return new s(t);
throw Error("illegal buffer")
}
;
function f() {
var t = new o(0,0)
, e = 0;
if (!(4 < this.len - this.pos)) {
for (; e < 3; ++e) {
if (this.pos >= this.len)
throw a(this);
if (t.lo = (t.lo | (127 & this.buf[this.pos]) << 7 * e) >>> 0,
this.buf[this.pos++] < 128)
return t
}
return t.lo = (t.lo | (127 & this.buf[this.pos++]) << 7 * e) >>> 0,
t
}
for (; e < 4; ++e)
if (t.lo = (t.lo | (127 & this.buf[this.pos]) << 7 * e) >>> 0,
this.buf[this.pos++] < 128)
return t;
if (t.lo = (t.lo | (127 & this.buf[this.pos]) << 28) >>> 0,
t.hi = (t.hi | (127 & this.buf[this.pos]) >> 4) >>> 0,
this.buf[this.pos++] < 128)
return t;
if (e = 0,
4 < this.len - this.pos) {
for (; e < 5; ++e)
if (t.hi = (t.hi | (127 & this.buf[this.pos]) << 7 * e + 3) >>> 0,
this.buf[this.pos++] < 128)
return t
} else
for (; e < 5; ++e) {
if (this.pos >= this.len)
throw a(this);
if (t.hi = (t.hi | (127 & this.buf[this.pos]) << 7 * e + 3) >>> 0,
this.buf[this.pos++] < 128)
return t
}
throw Error("invalid varint encoding")
}
function d(t, e) {
return (t[e - 4] | t[e - 3] << 8 | t[e - 2] << 16 | t[e - 1] << 24) >>> 0
}
function l() {
if (this.pos + 8 > this.len)
throw a(this, 8);
return new o(d(this.buf, this.pos += 4),d(this.buf, this.pos += 4))
}
s.create = r.Buffer ? function(t) {
return (s.create = function(t) {
return r.Buffer.isBuffer(t) ? new n(t) : c(t)
}
)(t)
}
: c,
s.prototype.i = r.Array.prototype.subarray || r.Array.prototype.slice,
s.prototype.uint32 = (u = 4294967295,
function() {
if (u = (127 & this.buf[this.pos]) >>> 0,
this.buf[this.pos++] < 128)
return u;
if (u = (u | (127 & this.buf[this.pos]) << 7) >>> 0,
this.buf[this.pos++] < 128)
return u;
if (u = (u | (127 & this.buf[this.pos]) << 14) >>> 0,
this.buf[this.pos++] < 128)
return u;
if (u = (u | (127 & this.buf[this.pos]) << 21) >>> 0,
this.buf[this.pos++] < 128)
return u;
if (u = (u | (15 & this.buf[this.pos]) << 28) >>> 0,
this.buf[this.pos++] < 128)
return u;
if ((this.pos += 5) > this.len)
throw this.pos = this.len,
a(this, 10);
return u
}
),
s.prototype.int32 = function() {
return 0 | this.uint32()
}
,
s.prototype.sint32 = function() {
var t = this.uint32();
return t >>> 1 ^ -(1 & t) | 0
}
,
s.prototype.bool = function() {
return 0 !== this.uint32()
}
,
s.prototype.fixed32 = function() {
if (this.pos + 4 > this.len)
throw a(this, 4);
return d(this.buf, this.pos += 4)
}
,
s.prototype.sfixed32 = function() {
if (this.pos + 4 > this.len)
throw a(this, 4);
return 0 | d(this.buf, this.pos += 4)
}
,
s.prototype.float = function() {
if (this.pos + 4 > this.len)
throw a(this, 4);
var t = r.float.readFloatLE(this.buf, this.pos);
return this.pos += 4,
t
}
,
s.prototype.double = function() {
if (this.pos + 8 > this.len)
throw a(this, 4);
var t = r.float.readDoubleLE(this.buf, this.pos);
return this.pos += 8,
t
}
,
s.prototype.bytes = function() {
var t = this.uint32()
, e = this.pos
, n = this.pos + t;
if (n > this.len)
throw a(this, t);
return this.pos += t,
Array.isArray(this.buf) ? this.buf.slice(e, n) : e === n ? new this.buf.constructor(0) : this.i.call(this.buf, e, n)
}
,
s.prototype.string = function() {
var t = this.bytes();
return i.read(t, 0, t.length)
}
,
s.prototype.skip = function(t) {
if ("number" == typeof t) {
if (this.pos + t > this.len)
throw a(this, t);
this.pos += t
} else
do {
if (this.pos >= this.len)
throw a(this)
} while (128 & this.buf[this.pos++]);
return this
}
,
s.prototype.skipType = function(t) {
switch (t) {
case 0:
this.skip();
break;
case 1:
this.skip(8);
break;
case 2:
this.skip(this.uint32());
break;
case 3:
for (; 4 != (t = 7 & this.uint32()); )
this.skipType(t);
break;
case 5:
this.skip(4);
break;
default:
throw Error("invalid wire type " + t + " at offset " + this.pos)
}
return this
}
,
s.n = function(t) {
n = t;
var e = r.Long ? "toLong" : "toNumber";
r.merge(s.prototype, {
int64: function() {
return f.call(this)[e](!1)
},
uint64: function() {
return f.call(this)[e](!0)
},
sint64: function() {
return f.call(this).zzDecode()[e](!1)
},
fixed64: function() {
return l.call(this)[e](!0)
},
sfixed64: function() {
return l.call(this)[e](!1)
}
})
}
}
, {
15: 15
}],
10: [function(t, e) {
e.exports = o;
var n = t(9);
(o.prototype = Object.create(n.prototype)).constructor = o;
var r = t(15);
function o(t) {
n.call(this, t)
}
r.Buffer && (o.prototype.i = r.Buffer.prototype.slice),
o.prototype.string = function() {
var t = this.uint32();
return this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + t, this.len))
}
}
, {
15: 15,
9: 9
}],
11: [function(t, e) {
e.exports = {}
}
, {}],
12: [function(t, e, n) {
n.Service = t(13)
}
, {
13: 13
}],
13: [function(t, e) {
e.exports = r;
var n = t(15);
function r(t, e, r) {
if ("function" != typeof t)
throw TypeError("rpcImpl must be a function");
n.EventEmitter.call(this),
this.rpcImpl = t,
this.requestDelimited = !!e,
this.responseDelimited = !!r
}
((r.prototype = Object.create(n.EventEmitter.prototype)).constructor = r).prototype.rpcCall = function t(e, r, o, i, a) {
if (!i)
throw TypeError("request must be specified");
var s = this;
if (!a)
return n.asPromise(t, s, e, r, o, i);
if (!s.rpcImpl)
return setTimeout((function() {
a(Error("already ended"))
}
), 0),
b;
try {
return s.rpcImpl(e, r[s.requestDelimited ? "encodeDelimited" : "encode"](i).finish(), (function(t, n) {
if (t)
return s.emit("error", t, e),
a(t);
if (null === n)
return s.end(!0),
b;
if (!(n instanceof o))
try {
n = o[s.responseDelimited ? "decodeDelimited" : "decode"](n)
} catch (t) {
return s.emit("error", t, e),
a(t)
}
return s.emit("data", n, e),
a(null, n)
}
))
} catch (t) {
return s.emit("error", t, e),
setTimeout((function() {
a(t)
}
), 0),
b
}
}
,
r.prototype.end = function(t) {
return this.rpcImpl && (t || this.rpcImpl(null, null, null),
this.rpcImpl = null,
this.emit("end").off()),
this
}
}
, {
15: 15
}],
14: [function(t, e) {
e.exports = r;
var n = t(15);
function r(t, e) {
this.lo = t >>> 0,
this.hi = e >>> 0
}
var o = r.zero = new r(0,0);
o.toNumber = function() {
return 0
}
,
o.zzEncode = o.zzDecode = function() {
return this
}
,
o.length = function() {
return 1
}
;
var i = r.zeroHash = "\0\0\0\0\0\0\0\0";
r.fromNumber = function(t) {
if (0 === t)
return o;
var e = t < 0;
e && (t = -t);
var n = t >>> 0
, i = (t - n) / 4294967296 >>> 0;
return e && (i = ~i >>> 0,
n = ~n >>> 0,
4294967295 < ++n && (n = 0,
4294967295 < ++i && (i = 0))),
new r(n,i)
}
,
r.from = function(t) {
if ("number" == typeof t)
return r.fromNumber(t);
if (n.isString(t)) {
if (!n.Long)
return r.fromNumber(parseInt(t, 10));
t = n.Long.fromString(t)
}
return t.low || t.high ? new r(t.low >>> 0,t.high >>> 0) : o
}
,
r.prototype.toNumber = function(t) {
if (!t && this.hi >>> 31) {
var e = 1 + ~this.lo >>> 0
, n = ~this.hi >>> 0;
return e || (n = n + 1 >>> 0),
-(e + 4294967296 * n)
}
return this.lo + 4294967296 * this.hi
}
,
r.prototype.toLong = function(t) {
return n.Long ? new n.Long(0 | this.lo,0 | this.hi,!!t) : {
low: 0 | this.lo,
high: 0 | this.hi,
unsigned: !!t
}
}
;
var a = String.prototype.charCodeAt;
r.fromHash = function(t) {
return t === i ? o : new r((a.call(t, 0) | a.call(t, 1) << 8 | a.call(t, 2) << 16 | a.call(t, 3) << 24) >>> 0,(a.call(t, 4) | a.call(t, 5) << 8 | a.call(t, 6) << 16 | a.call(t, 7) << 24) >>> 0)
}
,
r.prototype.toHash = function() {
return String.fromCharCode(255 & this.lo, this.lo >>> 8 & 255, this.lo >>> 16 & 255, this.lo >>> 24, 255 & this.hi, this.hi >>> 8 & 255, this.hi >>> 16 & 255, this.hi >>> 24)
}
,
r.prototype.zzEncode = function() {
var t = this.hi >> 31;
return this.hi = ((this.hi << 1 | this.lo >>> 31) ^ t) >>> 0,
this.lo = (this.lo << 1 ^ t) >>> 0,
this
}
,
r.prototype.zzDecode = function() {
var t = -(1 & this.lo);
return this.lo = ((this.lo >>> 1 | this.hi << 31) ^ t) >>> 0,
this.hi = (this.hi >>> 1 ^ t) >>> 0,
this
}
,
r.prototype.length = function() {
var t = this.lo
, e = (this.lo >>> 28 | this.hi << 4) >>> 0
, n = this.hi >>> 24;
return 0 === n ? 0 === e ? t < 16384 ? t < 128 ? 1 : 2 : t < 2097152 ? 3 : 4 : e < 16384 ? e < 128 ? 5 : 6 : e < 2097152 ? 7 : 8 : n < 128 ? 9 : 10
}
}
, {
15: 15
}],
15: [function(t, e, n) {
var r = n;
function o(t, e, n) {
for (var r = Object.keys(e), o = 0; o < r.length; ++o)
t[r[o]] !== b && n || (t[r[o]] = e[r[o]]);
return t
}
function i(t) {
function e(t, n) {
if (!(this instanceof e))
return new e(t,n);
Object.defineProperty(this, "message", {
get: function() {
return t
}
}),
Error.captureStackTrace ? Error.captureStackTrace(this, e) : Object.defineProperty(this, "stack", {
value: Error().stack || ""
}),
n && o(this, n)
}
return (e.prototype = Object.create(Error.prototype)).constructor = e,
Object.defineProperty(e.prototype, "name", {
get: function() {
return t
}
}),
e.prototype.toString = function() {
return this.name + ": " + this.message
}
,
e
}
r.asPromise = t(1),
r.base64 = t(2),
r.EventEmitter = t(3),
r.float = t(4),
r.inquire = t(5),
r.utf8 = t(7),
r.pool = t(6),
r.LongBits = t(14),
r.global = "undefined" != typeof window && window || void 0 !== global && global || "undefined" != typeof self && self || this,
r.emptyArray = Object.freeze ? Object.freeze([]) : [],
r.emptyObject = Object.freeze ? Object.freeze({}) : {},
r.isNode = !!(r.global.process && r.global.process.versions && r.global.process.versions.node),
r.isInteger = Number.isInteger || function(t) {
return "number" == typeof t && isFinite(t) && Math.floor(t) === t
}
,
r.isString = function(t) {
return "string" == typeof t || t instanceof String
}
,
r.isObject = function(t) {
return t && "object" == _typeof(t)
}
,
r.isset = r.isSet = function(t, e) {
var n = t[e];
return !(null == n || !t.hasOwnProperty(e)) && ("object" != _typeof(n) || 0 < (Array.isArray(n) ? n.length : Object.keys(n).length))
}
,
r.Buffer = function() {
try {
var t = r.inquire("buffer").Buffer;
return t.prototype.utf8Write ? t : null
} catch (t) {
return null
}
}(),
r.r = null,
r.u = null,
r.newBuffer = function(t) {
return "number" == typeof t ? r.Buffer ? r.u(t) : new r.Array(t) : r.Buffer ? r.r(t) : "undefined" == typeof Uint8Array ? t : new Uint8Array(t)
}
,
r.Array = "undefined" != typeof Uint8Array ? Uint8Array : Array,
r.Long = r.global.dcodeIO && r.global.dcodeIO.Long || r.global.Long || r.inquire("long"),
r.key2Re = /^true|false|0|1$/,
r.key32Re = /^-?(?:0|[1-9][0-9]*)$/,
r.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,
r.longToHash = function(t) {
return t ? r.LongBits.from(t).toHash() : r.LongBits.zeroHash
}
,
r.longFromHash = function(t, e) {
var n = r.LongBits.fromHash(t);
return r.Long ? r.Long.fromBits(n.lo, n.hi, e) : n.toNumber(!!e)
}
,
r.merge = o,
r.lcFirst = function(t) {
return t.charAt(0).toLowerCase() + t.substring(1)
}
,
r.newError = i,
r.ProtocolError = i("ProtocolError"),
r.oneOfGetter = function(t) {
for (var e = {}, n = 0; n < t.length; ++n)
e[t[n]] = 1;
return function() {
for (var t = Object.keys(this), n = t.length - 1; -1 < n; --n)
if (1 === e[t[n]] && this[t[n]] !== b && null !== this[t[n]])
return t[n]
}
}
,
r.oneOfSetter = function(t) {
return function(e) {
for (var n = 0; n < t.length; ++n)
t[n] !== e && delete this[t[n]]
}
}
,
r.toJSONOptions = {
longs: String,
enums: String,
bytes: String,
json: !0
},
r.n = function() {
var t = r.Buffer;
t ? (r.r = t.from !== Uint8Array.from && t.from || function(e, n) {
return new t(e,n)
}
,
r.u = t.allocUnsafe || function(e) {
return new t(e)
}
) : r.r = r.u = null
}
}
, {
1: 1,
14: 14,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7
}],
16: [function(t, e) {
e.exports = f;
var n, r = t(15), o = r.LongBits, i = r.base64, a = r.utf8;
function s(t, e, n) {
this.fn = t,
this.len = e,
this.next = b,
this.val = n
}
function u() {}
function c(t) {
this.head = t.head,
this.tail = t.tail,
this.len = t.len,
this.next = t.states
}
function f() {
this.len = 0,
this.head = new s(u,0,0),
this.tail = this.head,
this.states = null
}
function d(t, e, n) {
e[n] = 255 & t
}
function l(t, e) {
this.len = t,
this.next = b,
this.val = e
}
function p(t, e, n) {
for (; t.hi; )
e[n++] = 127 & t.lo | 128,
t.lo = (t.lo >>> 7 | t.hi << 25) >>> 0,
t.hi >>>= 7;
for (; 127 < t.lo; )
e[n++] = 127 & t.lo | 128,
t.lo = t.lo >>> 7;
e[n++] = t.lo
}
function h(t, e, n) {
e[n] = 255 & t,
e[n + 1] = t >>> 8 & 255,
e[n + 2] = t >>> 16 & 255,
e[n + 3] = t >>> 24
}
f.create = false ? function() {
return (f.create = function() {
return new n
}
)()
}
: function() {
return new f
}
,
f.alloc = function(t) {
return new r.Array(t)
}
,
r.Array !== Array && (f.alloc = r.pool(f.alloc, r.Array.prototype.subarray)),
f.prototype.e = function(t, e, n) {
return this.tail = this.tail.next = new s(t,e,n),
this.len += e,
this
}
,
(l.prototype = Object.create(s.prototype)).fn = function(t, e, n) {
for (; 127 < t; )
e[n++] = 127 & t | 128,
t >>>= 7;
e[n] = t
}
,
f.prototype.uint32 = function(t) {
return this.len += (this.tail = this.tail.next = new l((t >>>= 0) < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5,t)).len,
this
}
,
f.prototype.int32 = function(t) {
return t < 0 ? this.e(p, 10, o.fromNumber(t)) : this.uint32(t)
}
,
f.prototype.sint32 = function(t) {
return this.uint32((t << 1 ^ t >> 31) >>> 0)
}
,
f.prototype.int64 = f.prototype.uint64 = function(t) {
var e = o.from(t);
return this.e(p, e.length(), e)
}
,
f.prototype.sint64 = function(t) {
var e = o.from(t).zzEncode();
return this.e(p, e.length(), e)
}
,
f.prototype.bool = function(t) {
return this.e(d, 1, t ? 1 : 0)
}
,
f.prototype.sfixed32 = f.prototype.fixed32 = function(t) {
return this.e(h, 4, t >>> 0)
}
,
f.prototype.sfixed64 = f.prototype.fixed64 = function(t) {
var e = o.from(t);
return this.e(h, 4, e.lo).e(h, 4, e.hi)
}
,
f.prototype.float = function(t) {
return this.e(r.float.writeFloatLE, 4, t)
}
,
f.prototype.double = function(t) {
return this.e(r.float.writeDoubleLE, 8, t)
}
;
var m = r.Array.prototype.set ? function(t, e, n) {
e.set(t, n)
}
: function(t, e, n) {
for (var r = 0; r < t.length; ++r)
e[n + r] = t[r]
}
;
f.prototype.bytes = function(t) {
var e = t.length >>> 0;
if (!e)
return this.e(d, 1, 0);
if (r.isString(t)) {
var n = f.alloc(e = i.length(t));
i.decode(t, n, 0),
t = n
}
return this.uint32(e).e(m, e, t)
}
,
f.prototype.string = function(t) {
var e = a.length(t);
return e ? this.uint32(e).e(a.write, e, t) : this.e(d, 1, 0)
}
,
f.prototype.fork = function() {
return this.states = new c(this),
this.head = this.tail = new s(u,0,0),
this.len = 0,
this
}
,
f.prototype.reset = function() {
return this.states ? (this.head = this.states.head,
this.tail = this.states.tail,
this.len = this.states.len,
this.states = this.states.next) : (this.head = this.tail = new s(u,0,0),
this.len = 0),
this
}
,
f.prototype.ldelim = function() {
var t = this.head
, e = this.tail
, n = this.len;
return this.reset().uint32(n),
n && (this.tail.next = t.next,
this.tail = e,
this.len += n),
this
}
,
f.prototype.finish = function() {
for (var t = this.head.next, e = this.constructor.alloc(this.len), n = 0; t; )
t.fn(t.val, e, n),
n += t.len,
t = t.next;
return e
}
,
f.n = function(t) {
n = t
}
}
, {
15: 15
}],
17: [function(t, e) {
e.exports = i;
var n = t(16);
(i.prototype = Object.create(n.prototype)).constructor = i;
var r = t(15)
, o = r.Buffer;
function i() {
n.call(this)
}
i.alloc = function(t) {
return (i.alloc = r.u)(t)
}
;
var a = o && o.prototype instanceof Uint8Array && "set" === o.prototype.set.name ? function(t, e, n) {
e.set(t, n)
}
: function(t, e, n) {
if (t.copy)
t.copy(e, n, 0, t.length);
else
for (var r = 0; r < t.length; )
e[n++] = t[r++]
}
;
function s(t, e, n) {
t.length < 40 ? r.utf8.write(t, e, n) : e.utf8Write(t, n)
}
i.prototype.bytes = function(t) {
r.isString(t) && (t = r.r(t, "base64"));
var e = t.length >>> 0;
return this.uint32(e),
e && this.e(a, e, t),
this
}
,
i.prototype.string = function(t) {
var e = o.byteLength(t);
return this.uint32(e),
e && this.e(s, e, t),
this
}
}
, {
15: 15,
16: 16
}]
},
u = {},
t = [8],
n = function t(e) {
var n = u[e];
return n || r[e][0].call(n = u[e] = {
exports: {}
}, t, n, n.exports),
n.exports
}
;
window.nnnnnn = n
}()
yt = {
Writer: window.nnnnnn(16)
}
var zdecode = function(t, n, count) {
window.nnnnnn(16).n();
if (count == 1){
var e = {
"1": [
"titanid",
"string",
""
],
"3": [
"ua",
"string",
""
],
"4": [
"os",
"uint32",
0
],
"5": [
"uid",
"string",
""
],
"11": [
"repackage",
"bool",
false
],
"12": [
"accesstoken",
"string",
""
],
"13": [
"customPayload",
"{string,bytes",
null
],
"17": [
"authType",
"uint32",
0
],
"19": [
"sceneType",
"uint32",
0
]
}
}
else if (count == 2){
var e = {
"7": [
"encryptedAppInfo",
"bytes",
[]
],
"10": [
"requestType",
"uint32",
0
],
"11": [
"protocolVersion",
"uint32",
0
],
"12": [
"isPushConn",
"bool",
false
]
}
}
else{
var e = {
"1": [
"appId",
"uint32",
0
],
"2": [
"command",
"string",
""
],
"3": [
"protocol",
"uint32",
0
],
"4": [
"compress",
"uint32",
0
],
"6": [
"host",
"string",
""
],
"7": [
"appinfo",
"bytes",
[]
],
"8": [
"sessionResumptionReq",
"bytes",
[]
],
"9": [
"body",
"bytes",
[]
],
"11": [
"upstreamSeq",
"uint64",
0
],
"12": [
"conId",
"uint64",
0
],
"13": [
"ctxId",
"uint64",
0
],
"14": [
"keyInfo",
"default.base.msg.MulticastGroupKeyInfo",
null
]
}
}
for (var i in n = n || yt.Writer.create(),
e) {
var a = e[i][0];
if ("{" === (f = e[i][1]).charAt(0)) {
if (null != t[a] && t.hasOwnProperty(a))
for (var s = 0, u = Object.keys(t[a]); s < u.length; ++s)
n.uint32((i << 3 | 2) >> 0).fork(),
zdecode({
$1: u[s],
$2: t[a][u[s]]
}, n).ldelim()
} else if ("[" === f.charAt(0) || "<" === f.charAt(0)) {
var c = "<" === f.charAt(0)
, f = f.substring(1)
, d = t[a];
if (null != d && d.length)
if (c && void 0 !== bt[f]) {
for (n.uint32((i << 3 | 2) >> 0).fork(),
s = 0; s < d.length; s++)
window.nnnnnn(16).prototype[f].call(n, d[s]);
n.ldelim()
} else
for (s = 0; s < d.length; s++)
window.nnnnnn(16).prototype[f].call(n, d[s], i)
} else
var t__ = {
"double": 1,
"float": 5,
"int32": 0,
"uint32": 0,
"sint32": 0,
"fixed32": 5,
"sfixed32": 5,
"int64": 0,
"uint64": 0,
"sint64": 0,
"fixed64": 1,
"sfixed64": 1,
"bool": 0,
"string": 2,
"bytes": 2
};
var rr = t__[f];
null != t[a] && t.hasOwnProperty(a) && window.nnnnnn(16).prototype[f].call(n.uint32(i << 3 | rr), t[a])
}
return n
}
function arrayBufferToBase64(buffer) {
let binary = '';
const bytes = new Uint8Array(buffer);
for (let i = 0; i < bytes.byteLength; i++) {
binary += String.fromCharCode(bytes[i]);
}
return btoa(binary);
}
function encode_token(titanid, accesstoken){
aaa = zdecode({
"titanid": titanid,
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"os": 5,
"uid": titanid,
"repackage": false,
"accesstoken": accesstoken,
"authType": 4,
"sceneType": 1001
}, undefined, 1).finish()
zzz = zdecode({
"encryptedAppInfo": aaa,
"isPushConn": true,
"protocolVersion": 1,
"requestType": 4
}, undefined, 2).finish()
ddd = zdecode({
"appId": 2,
"command": "titan.session",
"compress": 0,
"host": "mms.pinduoduo.com",
"protocol": 1,
"sessionResumptionReq": zzz,
"upstreamSeq": 101
}, undefined, 3).finish()
var i = ddd && ddd.byteLength || 0;
var a = new ArrayBuffer(16 + i);
var gg = new DataView(a);
gg.setInt16(0, 10, !1);
gg.setInt16(2, 102, !1);
gg.setInt32(4, 101, !1);
gg.setInt32(8, 1, !1);
gg.setInt32(12, i, !1);
for (let t = 0; t < i; t++){
gg.setUint8(16 + t, ddd[t], !1);
}
// 方法1: 使用循环读取所有字节到数组
const resultArray1 = [];
for (let offset = 0; offset < gg.byteLength; offset++) {
resultArray1.push(gg.getUint8(offset));
}
return resultArray1
}
// console.log(encode_token())