diff --git a/manifest.json b/manifest.json index 9542df7..59d0e6e 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "LLOneBot", "slug": "LLOneBot", "description": "实现 OneBot 11 和 Satori 协议,用于 QQ 机器人开发", - "version": "4.3.1", + "version": "4.3.2", "icon": "./icon.webp", "authors": [ { diff --git a/src/ntqqapi/native/napcat-protocol-packet/index.d.ts b/src/ntqqapi/native/napcat-protocol-packet/index.d.ts index e53be46..e586a92 100644 --- a/src/ntqqapi/native/napcat-protocol-packet/index.d.ts +++ b/src/ntqqapi/native/napcat-protocol-packet/index.d.ts @@ -1,13 +1,13 @@ import { WrapperSession } from './wrapper-session/types'; export { initWrapperSession } from './wrapper-session'; +export declare function checkSupportVersion(): void; export declare class NTQQPacketApi { private qqVersion; - private packetSession; + private readonly packetClient; + private readonly packer; private logger; private readonly wrapperSession; constructor(wrapperSession: WrapperSession); - get available(): boolean; - private checkQQVersion; private InitSendPacket; private sendPacket; private sendOidbPacket; diff --git a/src/ntqqapi/native/napcat-protocol-packet/index.mjs b/src/ntqqapi/native/napcat-protocol-packet/index.mjs index e6ec3a0..1164bd2 100644 --- a/src/ntqqapi/native/napcat-protocol-packet/index.mjs +++ b/src/ntqqapi/native/napcat-protocol-packet/index.mjs @@ -1,4135 +1,106 @@ -import _0x36934c from 'os'; -import require$$0$2 from 'stream'; -import require$$0 from 'zlib'; -import require$$0$1 from 'buffer'; -import require$$1$1, { createHash as createHash$1 } from 'crypto'; -import require$$0$3 from 'events'; -import require$$1$2 from 'https'; -import require$$2$1 from 'http'; -import require$$3 from 'net'; -import require$$4 from 'tls'; -import require$$7, { fileURLToPath } from 'url'; -import _0x12fc62, { dirname } from 'path'; -import _0x2e82e7 from 'fs'; -import _0x9ba475, { constants as constants$1 } from 'node:os'; -import _0x46a3d9 from 'node:fs'; -import _0x26c41f from 'node:path'; +import _0x2a5b9e from 'os'; +import _0x28dee6 from 'node:fs'; +import _0x5acf7e, { constants } from 'node:os'; +import _0x56d2e7 from 'node:path'; +import _0x2cf5c6, { createHash } from 'crypto'; +import _0x49c13c, { dirname } from 'path'; +import { fileURLToPath } from 'url'; +import _0x3f08f4 from 'fs'; -function _0x2051(_0x2b1d9e,_0x3a8d8f){const _0xae070d=_0xae07();return _0x2051=function(_0x2051c6,_0x3b6f4d){_0x2051c6=_0x2051c6-0x16c;let _0x4dffbc=_0xae070d[_0x2051c6];return _0x4dffbc;},_0x2051(_0x2b1d9e,_0x3a8d8f);}const _0x449c89=_0x2051;function _0xae07(){const _0x19112f=['2161825fPcZka','next','4QIJdVb','keys','2020NwDiij','get','set','capacity','443878ejdriG','size','381570lTBGLA','488571SBUJxB','has','81544XWyran','value','delete','353195NIMajS','301PcJEKX','46080OJzJMc','cache'];_0xae07=function(){return _0x19112f;};return _0xae07();}(function(_0x58ef35,_0x10f386){const _0xf02df1=_0x2051,_0x3aa9f4=_0x58ef35();while(!![]){try{const _0x5abfeb=-parseInt(_0xf02df1(0x174))/0x1+parseInt(_0xf02df1(0x16c))/0x2+parseInt(_0xf02df1(0x16f))/0x3+-parseInt(_0xf02df1(0x17a))/0x4*(parseInt(_0xf02df1(0x178))/0x5)+parseInt(_0xf02df1(0x16e))/0x6+parseInt(_0xf02df1(0x175))/0x7*(-parseInt(_0xf02df1(0x171))/0x8)+-parseInt(_0xf02df1(0x176))/0x9*(-parseInt(_0xf02df1(0x17c))/0xa);if(_0x5abfeb===_0x10f386)break;else _0x3aa9f4['push'](_0x3aa9f4['shift']());}catch(_0x1bb2d8){_0x3aa9f4['push'](_0x3aa9f4['shift']());}}}(_0xae07,0x3f2d4));class LRUCache{[_0x449c89(0x17f)];['cache'];constructor(_0x20b327){const _0x139bd3=_0x449c89;this[_0x139bd3(0x17f)]=_0x20b327,this['cache']=new Map();}[_0x449c89(0x17d)](_0x15fcfd){const _0x2bcab6=_0x449c89,_0x2e860e=this[_0x2bcab6(0x177)][_0x2bcab6(0x17d)](_0x15fcfd);return _0x2e860e!==void 0x0&&(this[_0x2bcab6(0x177)][_0x2bcab6(0x173)](_0x15fcfd),this[_0x2bcab6(0x177)][_0x2bcab6(0x17e)](_0x15fcfd,_0x2e860e)),_0x2e860e;}['put'](_0x3cb1e5,_0x4e9771){const _0x3c784c=_0x449c89;if(this['cache'][_0x3c784c(0x170)](_0x3cb1e5))this['cache'][_0x3c784c(0x173)](_0x3cb1e5);else {if(this[_0x3c784c(0x177)][_0x3c784c(0x16d)]>=this['capacity']){const _0x422410=this['cache'][_0x3c784c(0x17b)]()[_0x3c784c(0x179)]()[_0x3c784c(0x172)];_0x422410!==void 0x0&&this[_0x3c784c(0x177)][_0x3c784c(0x173)](_0x422410);}}this[_0x3c784c(0x177)][_0x3c784c(0x17e)](_0x3cb1e5,_0x4e9771);}} - -function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +const _0x49b86f = { + "3.2.12-28418-x64": { + recv: "A0723E0", + send: "A06EAE0" +}, + "9.9.15-28418-x64": { + recv: "37A9004", + send: "37A4BD0" +}, + "6.9.56-28418-x64": { + send: "4471360", + recv: "4473BCC" +}, + "6.9.56-28418-arm64": { + send: "3FBDBF8", + recv: "3FC0410" +}, + "9.9.15-28498-x64": { + recv: "37A9004", + send: "37A4BD0" +}, + "9.9.16-28788-x64": { + send: "38076D0", + recv: "380BB04" +}, + "3.2.13-28788-x64": { + send: "A0CEC20", + recv: "A0D2520" +}, + "3.2.13-28788-arm64": { + send: "6E91018", + recv: "6E94850" +}, + "9.9.16-28971-x64": { + send: "38079F0", + recv: "380BE24" +}, + "3.2.13-28971-x64": { + send: "A0CEF60", + recv: "A0D2860" +}, + "3.2.12-28971-arm64": { + send: "6E91318", + recv: "6E94B50" +}, + "6.9.58-28971-x64": { + send: "449ACA0", + recv: "449D50C" +}, + "6.9.58-28971-arm64": { + send: "3FE0DB0", + recv: "3FE35C8" +}, + "9.9.16-29271-x64": { + send: "3833510", + recv: "3837944" +}, + "3.2.13-29271-x64": { + send: "A11E680", + recv: "A121F80" +}, + "3.2.13-29271-arm64": { + send: "6ECA098", + recv: "6ECD8D0" +}, + "9.9.16-29456-x64": { + send: "3835CD0", + recv: "383A104" +}, + "3.2.13-29456-x64": { + send: "A11E820", + recv: "A122120" +}, + "3.2.13-29456-arm64": { + send: "6ECA130", + recv: "6ECD968" +}, + "6.9.59-29456-x64": { + send: "44C57A0", + recv: "44C800C" +}, + "6.9.59-29456-arm64": { + send: "4005FE8", + recv: "4008800" } - -function getAugmentedNamespace(n) { - if (n.__esModule) return n; - var f = n.default; - if (typeof f == "function") { - var a = function a () { - if (this instanceof a) { - return Reflect.construct(f, arguments, this.constructor); - } - return f.apply(this, arguments); - }; - a.prototype = f.prototype; - } else a = {}; - Object.defineProperty(a, '__esModule', {value: true}); - Object.keys(n).forEach(function (k) { - var d = Object.getOwnPropertyDescriptor(n, k); - Object.defineProperty(a, k, d.get ? d : { - enumerable: true, - get: function () { - return n[k]; - } - }); - }); - return a; -} - -var bufferUtil$1 = {exports: {}}; - -const BINARY_TYPES$2 = ['nodebuffer', 'arraybuffer', 'fragments']; -const hasBlob$1 = typeof Blob !== 'undefined'; - -if (hasBlob$1) BINARY_TYPES$2.push('blob'); - -var constants = { - BINARY_TYPES: BINARY_TYPES$2, - EMPTY_BUFFER: Buffer.alloc(0), - GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11', - hasBlob: hasBlob$1, - kForOnEventAttribute: Symbol('kIsForOnEventAttribute'), - kListener: Symbol('kListener'), - kStatusCode: Symbol('status-code'), - kWebSocket: Symbol('websocket'), - NOOP: () => {} }; -const __viteOptionalPeerDep_bufferutil_ws = {}; +const _0x9f4f57=_0xb062;(function(_0x4677c7,_0x3eb97c){const _0x1ccef5=_0xb062,_0x53e660=_0x4677c7();while(!![]){try{const _0x2f199d=parseInt(_0x1ccef5(0x1ef))/0x1*(-parseInt(_0x1ccef5(0x1f2))/0x2)+parseInt(_0x1ccef5(0x20b))/0x3+parseInt(_0x1ccef5(0x1e0))/0x4+parseInt(_0x1ccef5(0x1e4))/0x5+parseInt(_0x1ccef5(0x1e7))/0x6*(-parseInt(_0x1ccef5(0x208))/0x7)+-parseInt(_0x1ccef5(0x200))/0x8*(-parseInt(_0x1ccef5(0x1ee))/0x9)+parseInt(_0x1ccef5(0x201))/0xa;if(_0x2f199d===_0x3eb97c)break;else _0x53e660['push'](_0x53e660['shift']());}catch(_0x174179){_0x53e660['push'](_0x53e660['shift']());}}}(_0x1bc5,0x9b131));function _0xb062(_0x40891e,_0x260035){const _0x1bc5a0=_0x1bc5();return _0xb062=function(_0xb062e3,_0x53be9e){_0xb062e3=_0xb062e3-0x1dd;let _0x38df80=_0x1bc5a0[_0xb062e3];return _0x38df80;},_0xb062(_0x40891e,_0x260035);}function getQQVersionConfigPath(_0x918a9c=''){const _0x230db1=_0xb062;let _0x3d95b6;if(_0x5acf7e[_0x230db1(0x1e5)]()===_0x230db1(0x1f7))_0x3d95b6=_0x56d2e7[_0x230db1(0x205)](_0x56d2e7[_0x230db1(0x1df)](_0x918a9c),_0x230db1(0x202),'config.json');else {if(_0x5acf7e[_0x230db1(0x1e5)]()===_0x230db1(0x1e1)){const _0x5e9365=_0x5acf7e[_0x230db1(0x1ed)](),_0x110794=_0x56d2e7[_0x230db1(0x209)](_0x5e9365,_0x230db1(0x20d));_0x3d95b6=_0x56d2e7[_0x230db1(0x209)](_0x110794,_0x230db1(0x1f8));}else {const _0x4554e8=_0x5acf7e[_0x230db1(0x1ed)](),_0x4dad9e=_0x56d2e7[_0x230db1(0x209)](_0x4554e8,_0x230db1(0x1fe));_0x3d95b6=_0x56d2e7['resolve'](_0x4dad9e,_0x230db1(0x1f8));}}if(typeof _0x3d95b6!==_0x230db1(0x1f1))return void 0x0;!_0x28dee6[_0x230db1(0x1ea)](_0x3d95b6)&&(_0x3d95b6=_0x56d2e7['join'](_0x56d2e7['dirname'](_0x918a9c),_0x230db1(0x1de)));if(!_0x28dee6[_0x230db1(0x1ea)](_0x3d95b6))return void 0x0;return _0x3d95b6;}function getDefaultQQVersionConfigInfo(){const _0x3ec987=_0xb062;if(_0x5acf7e[_0x3ec987(0x1e5)]()==='linux')return {'baseVersion':_0x3ec987(0x1eb),'curVersion':_0x3ec987(0x1eb),'prevVersion':'','onErrorVersions':[],'buildId':'27254'};if(_0x5acf7e[_0x3ec987(0x1e5)]()===_0x3ec987(0x1e1))return {'baseVersion':_0x3ec987(0x204),'curVersion':_0x3ec987(0x204),'prevVersion':'','onErrorVersions':[],'buildId':_0x3ec987(0x20c)};return {'baseVersion':_0x3ec987(0x1ec),'curVersion':_0x3ec987(0x1ec),'prevVersion':'','onErrorVersions':[],'buildId':_0x3ec987(0x1e8)};}function getQQPackageInfoPath(_0x347e02='',_0x111b72){const _0x46b74d=_0xb062;let _0x28040c;if(_0x5acf7e[_0x46b74d(0x1e5)]()===_0x46b74d(0x1e1))_0x28040c=_0x56d2e7[_0x46b74d(0x205)](_0x56d2e7['dirname'](_0x347e02),'..','Resources',_0x46b74d(0x1fa),_0x46b74d(0x1f0));else _0x5acf7e[_0x46b74d(0x1e5)]()===_0x46b74d(0x1ff)?_0x28040c=_0x56d2e7[_0x46b74d(0x205)](_0x56d2e7[_0x46b74d(0x1df)](_0x347e02),_0x46b74d(0x1e3)):_0x28040c=_0x56d2e7[_0x46b74d(0x205)](_0x56d2e7['dirname'](_0x347e02),'./versions/'+_0x111b72+'/resources/app/package.json');return !_0x28dee6[_0x46b74d(0x1ea)](_0x28040c)&&(_0x28040c=_0x56d2e7[_0x46b74d(0x205)](_0x56d2e7[_0x46b74d(0x1df)](_0x347e02),'./resources/app/versions/'+_0x111b72+_0x46b74d(0x1fc))),_0x28040c;}function _0x1bc5(){const _0x334962=['/package.json','buildVersion','./.config/QQ','linux','126248caydZS','239150ibEpMi','versions','toString','6.9.53.28060','join','QQPackageInfo','isQuickUpdate','3572471xnsCSs','resolve','QQ版本获取失败','597885ByrmVY','28060','./Library/Application\x20Support/QQ','QQVersionConfigPath','curVersion','./resources/app/versions/config.json','dirname','2097608bVvKWQ','darwin','getQQBuildStr','./resources/app/package.json','1935715lbDalU','platform','QQVersionConfig','6GMNuah','28131','parse','existsSync','3.2.12.28060','9.9.15-28131','homedir','567FIolDU','49171ArxfXt','package.json','string','40NtRnKT','QQMainPath','execPath','version','readFileSync','win32','./versions/config.json','getFullQQVersion','app','QQPackageInfoPath'];_0x1bc5=function(){return _0x334962;};return _0x1bc5();}class QQBasicInfoWrapper{[_0x9f4f57(0x1f3)];[_0x9f4f57(0x1fb)];[_0x9f4f57(0x20e)];[_0x9f4f57(0x207)];['QQVersionConfig'];['QQPackageInfo'];constructor(){const _0x5c4885=_0x9f4f57;this[_0x5c4885(0x1f3)]=process[_0x5c4885(0x1f4)],this[_0x5c4885(0x20e)]=getQQVersionConfigPath(this['QQMainPath']),this[_0x5c4885(0x207)]=!!this[_0x5c4885(0x20e)],this[_0x5c4885(0x1e6)]=this[_0x5c4885(0x207)]?JSON[_0x5c4885(0x1e9)](_0x28dee6[_0x5c4885(0x1f6)](this[_0x5c4885(0x20e)])[_0x5c4885(0x203)]()):getDefaultQQVersionConfigInfo(),this['QQPackageInfoPath']=getQQPackageInfoPath(this['QQMainPath'],this['QQVersionConfig']?.['curVersion']),this[_0x5c4885(0x206)]=JSON['parse'](_0x28dee6[_0x5c4885(0x1f6)](this[_0x5c4885(0x1fb)])[_0x5c4885(0x203)]());}[_0x9f4f57(0x1f9)](){const _0x233b9c=_0x9f4f57,_0x3fd736=this[_0x233b9c(0x207)]?this['QQVersionConfig']?.[_0x233b9c(0x1dd)]:this[_0x233b9c(0x206)]?.[_0x233b9c(0x1f5)];if(!_0x3fd736)throw new Error(_0x233b9c(0x20a));return _0x3fd736;}[_0x9f4f57(0x1e2)](){const _0x40ce22=_0x9f4f57;return this[_0x40ce22(0x207)]?this['QQVersionConfig']?.['buildId']:this['QQPackageInfo']?.[_0x40ce22(0x1fd)];}} -const __viteOptionalPeerDep_bufferutil_ws$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ - __proto__: null, - default: __viteOptionalPeerDep_bufferutil_ws -}, Symbol.toStringTag, { value: 'Module' })); +function _0x22bf(_0x34237f,_0x56dde9){const _0x24a9bc=_0x24a9();return _0x22bf=function(_0x22bf7d,_0x4e86a4){_0x22bf7d=_0x22bf7d-0xcc;let _0x3809a6=_0x24a9bc[_0x22bf7d];return _0x3809a6;},_0x22bf(_0x34237f,_0x56dde9);}function _0x24a9(){const _0x6cbc55=['6237jQBHqm','648ZiMKuJ','put','capacity','set','9345pkFJUj','3pYLDIv','size','4354662LFCsWC','cache','710inXWlP','703632HADUWz','2540716sHmGlu','get','keys','5tMhjcW','has','1067616FTokra','79623VbwceC','444ZBlNRc','delete'];_0x24a9=function(){return _0x6cbc55;};return _0x24a9();}const _0x513d87=_0x22bf;(function(_0x463d93,_0x5cad68){const _0x206d41=_0x22bf,_0x3a2262=_0x463d93();while(!![]){try{const _0x510c97=parseInt(_0x206d41(0xcf))/0x1+parseInt(_0x206d41(0xd5))/0x2+parseInt(_0x206d41(0xdf))/0x3*(parseInt(_0x206d41(0xd0))/0x4)+parseInt(_0x206d41(0xd3))/0x5*(-parseInt(_0x206d41(0xcc))/0x6)+-parseInt(_0x206d41(0xde))/0x7*(parseInt(_0x206d41(0xda))/0x8)+-parseInt(_0x206d41(0xd6))/0x9*(parseInt(_0x206d41(0xce))/0xa)+-parseInt(_0x206d41(0xd9))/0xb*(parseInt(_0x206d41(0xd7))/0xc);if(_0x510c97===_0x5cad68)break;else _0x3a2262['push'](_0x3a2262['shift']());}catch(_0xa1abe){_0x3a2262['push'](_0x3a2262['shift']());}}}(_0x24a9,0x5f1d7));class LRUCache{[_0x513d87(0xdc)];[_0x513d87(0xcd)];constructor(_0x417fc0){const _0x46f8e3=_0x513d87;this[_0x46f8e3(0xdc)]=_0x417fc0,this[_0x46f8e3(0xcd)]=new Map();}[_0x513d87(0xd1)](_0x2fa537){const _0x519fc3=_0x513d87,_0x2ca232=this['cache'][_0x519fc3(0xd1)](_0x2fa537);return _0x2ca232!==void 0x0&&(this[_0x519fc3(0xcd)][_0x519fc3(0xd8)](_0x2fa537),this[_0x519fc3(0xcd)][_0x519fc3(0xdd)](_0x2fa537,_0x2ca232)),_0x2ca232;}[_0x513d87(0xdb)](_0xfa015d,_0x730cf7){const _0x2f0c34=_0x513d87;if(this[_0x2f0c34(0xcd)][_0x2f0c34(0xd4)](_0xfa015d))this['cache']['delete'](_0xfa015d);else {if(this['cache'][_0x2f0c34(0xe0)]>=this[_0x2f0c34(0xdc)]){const _0x4f08b9=this[_0x2f0c34(0xcd)][_0x2f0c34(0xd2)]()['next']()['value'];_0x4f08b9!==void 0x0&&this[_0x2f0c34(0xcd)]['delete'](_0x4f08b9);}}this[_0x2f0c34(0xcd)][_0x2f0c34(0xdd)](_0xfa015d,_0x730cf7);}} -const require$$1 = /*@__PURE__*/getAugmentedNamespace(__viteOptionalPeerDep_bufferutil_ws$1); +const _0x240925=_0x18d6;function _0x1c4b(){const _0x5b901f=['2993940RyunOC','360828dmtzuR','115259ZCyTFA','2152456VUoLsm','4013317ZboZEv','4NPxKrs','1843827OUqdJL','v1.0.0','1985070zbSinf'];_0x1c4b=function(){return _0x5b901f;};return _0x1c4b();}function _0x18d6(_0x4021a2,_0x47853c){const _0x1c4b4d=_0x1c4b();return _0x18d6=function(_0x18d67c,_0x5e76b5){_0x18d67c=_0x18d67c-0xcb;let _0x175daf=_0x1c4b4d[_0x18d67c];return _0x175daf;},_0x18d6(_0x4021a2,_0x47853c);}(function(_0x2056d2,_0x56c165){const _0x57cb96=_0x18d6,_0x19b853=_0x2056d2();while(!![]){try{const _0x31ea70=parseInt(_0x57cb96(0xcb))/0x1+-parseInt(_0x57cb96(0xd3))/0x2+parseInt(_0x57cb96(0xcf))/0x3+-parseInt(_0x57cb96(0xce))/0x4*(parseInt(_0x57cb96(0xd1))/0x5)+parseInt(_0x57cb96(0xd2))/0x6+-parseInt(_0x57cb96(0xcd))/0x7+parseInt(_0x57cb96(0xcc))/0x8;if(_0x31ea70===_0x56c165)break;else _0x19b853['push'](_0x19b853['shift']());}catch(_0x4448ba){_0x19b853['push'](_0x19b853['shift']());}}}(_0x1c4b,0x54c14));const MoeHooVersion=_0x240925(0xd0); -var unmask$1; -var mask; - -const { EMPTY_BUFFER: EMPTY_BUFFER$3 } = constants; - -const FastBuffer$2 = Buffer[Symbol.species]; - -/** - * Merges an array of buffers into a new buffer. - * - * @param {Buffer[]} list The array of buffers to concat - * @param {Number} totalLength The total length of buffers in the list - * @return {Buffer} The resulting buffer - * @public - */ -function concat$1(list, totalLength) { - if (list.length === 0) return EMPTY_BUFFER$3; - if (list.length === 1) return list[0]; - - const target = Buffer.allocUnsafe(totalLength); - let offset = 0; - - for (let i = 0; i < list.length; i++) { - const buf = list[i]; - target.set(buf, offset); - offset += buf.length; - } - - if (offset < totalLength) { - return new FastBuffer$2(target.buffer, target.byteOffset, offset); - } - - return target; -} - -/** - * Masks a buffer using the given mask. - * - * @param {Buffer} source The buffer to mask - * @param {Buffer} mask The mask to use - * @param {Buffer} output The buffer where to store the result - * @param {Number} offset The offset at which to start writing - * @param {Number} length The number of bytes to mask. - * @public - */ -function _mask(source, mask, output, offset, length) { - for (let i = 0; i < length; i++) { - output[offset + i] = source[i] ^ mask[i & 3]; - } -} - -/** - * Unmasks a buffer using the given mask. - * - * @param {Buffer} buffer The buffer to unmask - * @param {Buffer} mask The mask to use - * @public - */ -function _unmask(buffer, mask) { - for (let i = 0; i < buffer.length; i++) { - buffer[i] ^= mask[i & 3]; - } -} - -/** - * Converts a buffer to an `ArrayBuffer`. - * - * @param {Buffer} buf The buffer to convert - * @return {ArrayBuffer} Converted buffer - * @public - */ -function toArrayBuffer$1(buf) { - if (buf.length === buf.buffer.byteLength) { - return buf.buffer; - } - - return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length); -} - -/** - * Converts `data` to a `Buffer`. - * - * @param {*} data The data to convert - * @return {Buffer} The buffer - * @throws {TypeError} - * @public - */ -function toBuffer$2(data) { - toBuffer$2.readOnly = true; - - if (Buffer.isBuffer(data)) return data; - - let buf; - - if (data instanceof ArrayBuffer) { - buf = new FastBuffer$2(data); - } else if (ArrayBuffer.isView(data)) { - buf = new FastBuffer$2(data.buffer, data.byteOffset, data.byteLength); - } else { - buf = Buffer.from(data); - toBuffer$2.readOnly = false; - } - - return buf; -} - -bufferUtil$1.exports = { - concat: concat$1, - mask: _mask, - toArrayBuffer: toArrayBuffer$1, - toBuffer: toBuffer$2, - unmask: _unmask -}; - -/* istanbul ignore else */ -if (!process.env.WS_NO_BUFFER_UTIL) { - try { - const bufferUtil = require$$1; - - mask = bufferUtil$1.exports.mask = function (source, mask, output, offset, length) { - if (length < 48) _mask(source, mask, output, offset, length); - else bufferUtil.mask(source, mask, output, offset, length); - }; - - unmask$1 = bufferUtil$1.exports.unmask = function (buffer, mask) { - if (buffer.length < 32) _unmask(buffer, mask); - else bufferUtil.unmask(buffer, mask); - }; - } catch (e) { - // Continue regardless of the error. - } -} - -var bufferUtilExports = bufferUtil$1.exports; - -const kDone = Symbol('kDone'); -const kRun = Symbol('kRun'); - -/** - * A very simple job queue with adjustable concurrency. Adapted from - * https://github.com/STRML/async-limiter - */ -let Limiter$1 = class Limiter { - /** - * Creates a new `Limiter`. - * - * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed - * to run concurrently - */ - constructor(concurrency) { - this[kDone] = () => { - this.pending--; - this[kRun](); - }; - this.concurrency = concurrency || Infinity; - this.jobs = []; - this.pending = 0; - } - - /** - * Adds a job to the queue. - * - * @param {Function} job The job to run - * @public - */ - add(job) { - this.jobs.push(job); - this[kRun](); - } - - /** - * Removes a job from the queue and runs it if possible. - * - * @private - */ - [kRun]() { - if (this.pending === this.concurrency) return; - - if (this.jobs.length) { - const job = this.jobs.shift(); - - this.pending++; - job(this[kDone]); - } - } -}; - -var limiter = Limiter$1; - -const zlib = require$$0; - -const bufferUtil = bufferUtilExports; -const Limiter = limiter; -const { kStatusCode: kStatusCode$2 } = constants; - -const FastBuffer$1 = Buffer[Symbol.species]; -const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]); -const kPerMessageDeflate = Symbol('permessage-deflate'); -const kTotalLength = Symbol('total-length'); -const kCallback = Symbol('callback'); -const kBuffers = Symbol('buffers'); -const kError$1 = Symbol('error'); - -// -// We limit zlib concurrency, which prevents severe memory fragmentation -// as documented in https://github.com/nodejs/node/issues/8871#issuecomment-250915913 -// and https://github.com/websockets/ws/issues/1202 -// -// Intentionally global; it's the global thread pool that's an issue. -// -let zlibLimiter; - -/** - * permessage-deflate implementation. - */ -let PerMessageDeflate$3 = class PerMessageDeflate { - /** - * Creates a PerMessageDeflate instance. - * - * @param {Object} [options] Configuration options - * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support - * for, or request, a custom client window size - * @param {Boolean} [options.clientNoContextTakeover=false] Advertise/ - * acknowledge disabling of client context takeover - * @param {Number} [options.concurrencyLimit=10] The number of concurrent - * calls to zlib - * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the - * use of a custom server window size - * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept - * disabling of server context takeover - * @param {Number} [options.threshold=1024] Size (in bytes) below which - * messages should not be compressed if context takeover is disabled - * @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on - * deflate - * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on - * inflate - * @param {Boolean} [isServer=false] Create the instance in either server or - * client mode - * @param {Number} [maxPayload=0] The maximum allowed message length - */ - constructor(options, isServer, maxPayload) { - this._maxPayload = maxPayload | 0; - this._options = options || {}; - this._threshold = - this._options.threshold !== undefined ? this._options.threshold : 1024; - this._isServer = !!isServer; - this._deflate = null; - this._inflate = null; - - this.params = null; - - if (!zlibLimiter) { - const concurrency = - this._options.concurrencyLimit !== undefined - ? this._options.concurrencyLimit - : 10; - zlibLimiter = new Limiter(concurrency); - } - } - - /** - * @type {String} - */ - static get extensionName() { - return 'permessage-deflate'; - } - - /** - * Create an extension negotiation offer. - * - * @return {Object} Extension parameters - * @public - */ - offer() { - const params = {}; - - if (this._options.serverNoContextTakeover) { - params.server_no_context_takeover = true; - } - if (this._options.clientNoContextTakeover) { - params.client_no_context_takeover = true; - } - if (this._options.serverMaxWindowBits) { - params.server_max_window_bits = this._options.serverMaxWindowBits; - } - if (this._options.clientMaxWindowBits) { - params.client_max_window_bits = this._options.clientMaxWindowBits; - } else if (this._options.clientMaxWindowBits == null) { - params.client_max_window_bits = true; - } - - return params; - } - - /** - * Accept an extension negotiation offer/response. - * - * @param {Array} configurations The extension negotiation offers/reponse - * @return {Object} Accepted configuration - * @public - */ - accept(configurations) { - configurations = this.normalizeParams(configurations); - - this.params = this._isServer - ? this.acceptAsServer(configurations) - : this.acceptAsClient(configurations); - - return this.params; - } - - /** - * Releases all resources used by the extension. - * - * @public - */ - cleanup() { - if (this._inflate) { - this._inflate.close(); - this._inflate = null; - } - - if (this._deflate) { - const callback = this._deflate[kCallback]; - - this._deflate.close(); - this._deflate = null; - - if (callback) { - callback( - new Error( - 'The deflate stream was closed while data was being processed' - ) - ); - } - } - } - - /** - * Accept an extension negotiation offer. - * - * @param {Array} offers The extension negotiation offers - * @return {Object} Accepted configuration - * @private - */ - acceptAsServer(offers) { - const opts = this._options; - const accepted = offers.find((params) => { - if ( - (opts.serverNoContextTakeover === false && - params.server_no_context_takeover) || - (params.server_max_window_bits && - (opts.serverMaxWindowBits === false || - (typeof opts.serverMaxWindowBits === 'number' && - opts.serverMaxWindowBits > params.server_max_window_bits))) || - (typeof opts.clientMaxWindowBits === 'number' && - !params.client_max_window_bits) - ) { - return false; - } - - return true; - }); - - if (!accepted) { - throw new Error('None of the extension offers can be accepted'); - } - - if (opts.serverNoContextTakeover) { - accepted.server_no_context_takeover = true; - } - if (opts.clientNoContextTakeover) { - accepted.client_no_context_takeover = true; - } - if (typeof opts.serverMaxWindowBits === 'number') { - accepted.server_max_window_bits = opts.serverMaxWindowBits; - } - if (typeof opts.clientMaxWindowBits === 'number') { - accepted.client_max_window_bits = opts.clientMaxWindowBits; - } else if ( - accepted.client_max_window_bits === true || - opts.clientMaxWindowBits === false - ) { - delete accepted.client_max_window_bits; - } - - return accepted; - } - - /** - * Accept the extension negotiation response. - * - * @param {Array} response The extension negotiation response - * @return {Object} Accepted configuration - * @private - */ - acceptAsClient(response) { - const params = response[0]; - - if ( - this._options.clientNoContextTakeover === false && - params.client_no_context_takeover - ) { - throw new Error('Unexpected parameter "client_no_context_takeover"'); - } - - if (!params.client_max_window_bits) { - if (typeof this._options.clientMaxWindowBits === 'number') { - params.client_max_window_bits = this._options.clientMaxWindowBits; - } - } else if ( - this._options.clientMaxWindowBits === false || - (typeof this._options.clientMaxWindowBits === 'number' && - params.client_max_window_bits > this._options.clientMaxWindowBits) - ) { - throw new Error( - 'Unexpected or invalid parameter "client_max_window_bits"' - ); - } - - return params; - } - - /** - * Normalize parameters. - * - * @param {Array} configurations The extension negotiation offers/reponse - * @return {Array} The offers/response with normalized parameters - * @private - */ - normalizeParams(configurations) { - configurations.forEach((params) => { - Object.keys(params).forEach((key) => { - let value = params[key]; - - if (value.length > 1) { - throw new Error(`Parameter "${key}" must have only a single value`); - } - - value = value[0]; - - if (key === 'client_max_window_bits') { - if (value !== true) { - const num = +value; - if (!Number.isInteger(num) || num < 8 || num > 15) { - throw new TypeError( - `Invalid value for parameter "${key}": ${value}` - ); - } - value = num; - } else if (!this._isServer) { - throw new TypeError( - `Invalid value for parameter "${key}": ${value}` - ); - } - } else if (key === 'server_max_window_bits') { - const num = +value; - if (!Number.isInteger(num) || num < 8 || num > 15) { - throw new TypeError( - `Invalid value for parameter "${key}": ${value}` - ); - } - value = num; - } else if ( - key === 'client_no_context_takeover' || - key === 'server_no_context_takeover' - ) { - if (value !== true) { - throw new TypeError( - `Invalid value for parameter "${key}": ${value}` - ); - } - } else { - throw new Error(`Unknown parameter "${key}"`); - } - - params[key] = value; - }); - }); - - return configurations; - } - - /** - * Decompress data. Concurrency limited. - * - * @param {Buffer} data Compressed data - * @param {Boolean} fin Specifies whether or not this is the last fragment - * @param {Function} callback Callback - * @public - */ - decompress(data, fin, callback) { - zlibLimiter.add((done) => { - this._decompress(data, fin, (err, result) => { - done(); - callback(err, result); - }); - }); - } - - /** - * Compress data. Concurrency limited. - * - * @param {(Buffer|String)} data Data to compress - * @param {Boolean} fin Specifies whether or not this is the last fragment - * @param {Function} callback Callback - * @public - */ - compress(data, fin, callback) { - zlibLimiter.add((done) => { - this._compress(data, fin, (err, result) => { - done(); - callback(err, result); - }); - }); - } - - /** - * Decompress data. - * - * @param {Buffer} data Compressed data - * @param {Boolean} fin Specifies whether or not this is the last fragment - * @param {Function} callback Callback - * @private - */ - _decompress(data, fin, callback) { - const endpoint = this._isServer ? 'client' : 'server'; - - if (!this._inflate) { - const key = `${endpoint}_max_window_bits`; - const windowBits = - typeof this.params[key] !== 'number' - ? zlib.Z_DEFAULT_WINDOWBITS - : this.params[key]; - - this._inflate = zlib.createInflateRaw({ - ...this._options.zlibInflateOptions, - windowBits - }); - this._inflate[kPerMessageDeflate] = this; - this._inflate[kTotalLength] = 0; - this._inflate[kBuffers] = []; - this._inflate.on('error', inflateOnError); - this._inflate.on('data', inflateOnData); - } - - this._inflate[kCallback] = callback; - - this._inflate.write(data); - if (fin) this._inflate.write(TRAILER); - - this._inflate.flush(() => { - const err = this._inflate[kError$1]; - - if (err) { - this._inflate.close(); - this._inflate = null; - callback(err); - return; - } - - const data = bufferUtil.concat( - this._inflate[kBuffers], - this._inflate[kTotalLength] - ); - - if (this._inflate._readableState.endEmitted) { - this._inflate.close(); - this._inflate = null; - } else { - this._inflate[kTotalLength] = 0; - this._inflate[kBuffers] = []; - - if (fin && this.params[`${endpoint}_no_context_takeover`]) { - this._inflate.reset(); - } - } - - callback(null, data); - }); - } - - /** - * Compress data. - * - * @param {(Buffer|String)} data Data to compress - * @param {Boolean} fin Specifies whether or not this is the last fragment - * @param {Function} callback Callback - * @private - */ - _compress(data, fin, callback) { - const endpoint = this._isServer ? 'server' : 'client'; - - if (!this._deflate) { - const key = `${endpoint}_max_window_bits`; - const windowBits = - typeof this.params[key] !== 'number' - ? zlib.Z_DEFAULT_WINDOWBITS - : this.params[key]; - - this._deflate = zlib.createDeflateRaw({ - ...this._options.zlibDeflateOptions, - windowBits - }); - - this._deflate[kTotalLength] = 0; - this._deflate[kBuffers] = []; - - this._deflate.on('data', deflateOnData); - } - - this._deflate[kCallback] = callback; - - this._deflate.write(data); - this._deflate.flush(zlib.Z_SYNC_FLUSH, () => { - if (!this._deflate) { - // - // The deflate stream was closed while data was being processed. - // - return; - } - - let data = bufferUtil.concat( - this._deflate[kBuffers], - this._deflate[kTotalLength] - ); - - if (fin) { - data = new FastBuffer$1(data.buffer, data.byteOffset, data.length - 4); - } - - // - // Ensure that the callback will not be called again in - // `PerMessageDeflate#cleanup()`. - // - this._deflate[kCallback] = null; - - this._deflate[kTotalLength] = 0; - this._deflate[kBuffers] = []; - - if (fin && this.params[`${endpoint}_no_context_takeover`]) { - this._deflate.reset(); - } - - callback(null, data); - }); - } -}; - -var permessageDeflate = PerMessageDeflate$3; - -/** - * The listener of the `zlib.DeflateRaw` stream `'data'` event. - * - * @param {Buffer} chunk A chunk of data - * @private - */ -function deflateOnData(chunk) { - this[kBuffers].push(chunk); - this[kTotalLength] += chunk.length; -} - -/** - * The listener of the `zlib.InflateRaw` stream `'data'` event. - * - * @param {Buffer} chunk A chunk of data - * @private - */ -function inflateOnData(chunk) { - this[kTotalLength] += chunk.length; - - if ( - this[kPerMessageDeflate]._maxPayload < 1 || - this[kTotalLength] <= this[kPerMessageDeflate]._maxPayload - ) { - this[kBuffers].push(chunk); - return; - } - - this[kError$1] = new RangeError('Max payload size exceeded'); - this[kError$1].code = 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH'; - this[kError$1][kStatusCode$2] = 1009; - this.removeListener('data', inflateOnData); - this.reset(); -} - -/** - * The listener of the `zlib.InflateRaw` stream `'error'` event. - * - * @param {Error} err The emitted error - * @private - */ -function inflateOnError(err) { - // - // There is no need to call `Zlib#close()` as the handle is automatically - // closed when an error is emitted. - // - this[kPerMessageDeflate]._inflate = null; - err[kStatusCode$2] = 1007; - this[kCallback](err); -} - -var validation = {exports: {}}; - -const __viteOptionalPeerDep_utf8Validate_ws = {}; - -const __viteOptionalPeerDep_utf8Validate_ws$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ - __proto__: null, - default: __viteOptionalPeerDep_utf8Validate_ws -}, Symbol.toStringTag, { value: 'Module' })); - -const require$$2 = /*@__PURE__*/getAugmentedNamespace(__viteOptionalPeerDep_utf8Validate_ws$1); - -var isValidUTF8_1; - -const { isUtf8 } = require$$0$1; - -const { hasBlob } = constants; - -// -// Allowed token characters: -// -// '!', '#', '$', '%', '&', ''', '*', '+', '-', -// '.', 0-9, A-Z, '^', '_', '`', a-z, '|', '~' -// -// tokenChars[32] === 0 // ' ' -// tokenChars[33] === 1 // '!' -// tokenChars[34] === 0 // '"' -// ... -// -// prettier-ignore -const tokenChars$1 = [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 15 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 - 31 - 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, // 32 - 47 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48 - 63 - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, // 80 - 95 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0 // 112 - 127 -]; - -/** - * Checks if a status code is allowed in a close frame. - * - * @param {Number} code The status code - * @return {Boolean} `true` if the status code is valid, else `false` - * @public - */ -function isValidStatusCode$2(code) { - return ( - (code >= 1000 && - code <= 1014 && - code !== 1004 && - code !== 1005 && - code !== 1006) || - (code >= 3000 && code <= 4999) - ); -} - -/** - * Checks if a given buffer contains only correct UTF-8. - * Ported from https://www.cl.cam.ac.uk/%7Emgk25/ucs/utf8_check.c by - * Markus Kuhn. - * - * @param {Buffer} buf The buffer to check - * @return {Boolean} `true` if `buf` contains only correct UTF-8, else `false` - * @public - */ -function _isValidUTF8(buf) { - const len = buf.length; - let i = 0; - - while (i < len) { - if ((buf[i] & 0x80) === 0) { - // 0xxxxxxx - i++; - } else if ((buf[i] & 0xe0) === 0xc0) { - // 110xxxxx 10xxxxxx - if ( - i + 1 === len || - (buf[i + 1] & 0xc0) !== 0x80 || - (buf[i] & 0xfe) === 0xc0 // Overlong - ) { - return false; - } - - i += 2; - } else if ((buf[i] & 0xf0) === 0xe0) { - // 1110xxxx 10xxxxxx 10xxxxxx - if ( - i + 2 >= len || - (buf[i + 1] & 0xc0) !== 0x80 || - (buf[i + 2] & 0xc0) !== 0x80 || - (buf[i] === 0xe0 && (buf[i + 1] & 0xe0) === 0x80) || // Overlong - (buf[i] === 0xed && (buf[i + 1] & 0xe0) === 0xa0) // Surrogate (U+D800 - U+DFFF) - ) { - return false; - } - - i += 3; - } else if ((buf[i] & 0xf8) === 0xf0) { - // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - if ( - i + 3 >= len || - (buf[i + 1] & 0xc0) !== 0x80 || - (buf[i + 2] & 0xc0) !== 0x80 || - (buf[i + 3] & 0xc0) !== 0x80 || - (buf[i] === 0xf0 && (buf[i + 1] & 0xf0) === 0x80) || // Overlong - (buf[i] === 0xf4 && buf[i + 1] > 0x8f) || - buf[i] > 0xf4 // > U+10FFFF - ) { - return false; - } - - i += 4; - } else { - return false; - } - } - - return true; -} - -/** - * Determines whether a value is a `Blob`. - * - * @param {*} value The value to be tested - * @return {Boolean} `true` if `value` is a `Blob`, else `false` - * @private - */ -function isBlob$2(value) { - return ( - hasBlob && - typeof value === 'object' && - typeof value.arrayBuffer === 'function' && - typeof value.type === 'string' && - typeof value.stream === 'function' && - (value[Symbol.toStringTag] === 'Blob' || - value[Symbol.toStringTag] === 'File') - ); -} - -validation.exports = { - isBlob: isBlob$2, - isValidStatusCode: isValidStatusCode$2, - isValidUTF8: _isValidUTF8, - tokenChars: tokenChars$1 -}; - -if (isUtf8) { - isValidUTF8_1 = validation.exports.isValidUTF8 = function (buf) { - return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf); - }; -} /* istanbul ignore else */ else if (!process.env.WS_NO_UTF_8_VALIDATE) { - try { - const isValidUTF8 = require$$2; - - isValidUTF8_1 = validation.exports.isValidUTF8 = function (buf) { - return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf); - }; - } catch (e) { - // Continue regardless of the error. - } -} - -var validationExports = validation.exports; - -const { Writable } = require$$0$2; - -const PerMessageDeflate$2 = permessageDeflate; -const { - BINARY_TYPES: BINARY_TYPES$1, - EMPTY_BUFFER: EMPTY_BUFFER$2, - kStatusCode: kStatusCode$1, - kWebSocket: kWebSocket$2 -} = constants; -const { concat, toArrayBuffer, unmask } = bufferUtilExports; -const { isValidStatusCode: isValidStatusCode$1, isValidUTF8 } = validationExports; - -const FastBuffer = Buffer[Symbol.species]; - -const GET_INFO = 0; -const GET_PAYLOAD_LENGTH_16 = 1; -const GET_PAYLOAD_LENGTH_64 = 2; -const GET_MASK = 3; -const GET_DATA = 4; -const INFLATING = 5; -const DEFER_EVENT = 6; - -/** - * HyBi Receiver implementation. - * - * @extends Writable - */ -let Receiver$1 = class Receiver extends Writable { - /** - * Creates a Receiver instance. - * - * @param {Object} [options] Options object - * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether - * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted - * multiple times in the same tick - * @param {String} [options.binaryType=nodebuffer] The type for binary data - * @param {Object} [options.extensions] An object containing the negotiated - * extensions - * @param {Boolean} [options.isServer=false] Specifies whether to operate in - * client or server mode - * @param {Number} [options.maxPayload=0] The maximum allowed message length - * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or - * not to skip UTF-8 validation for text and close messages - */ - constructor(options = {}) { - super(); - - this._allowSynchronousEvents = - options.allowSynchronousEvents !== undefined - ? options.allowSynchronousEvents - : true; - this._binaryType = options.binaryType || BINARY_TYPES$1[0]; - this._extensions = options.extensions || {}; - this._isServer = !!options.isServer; - this._maxPayload = options.maxPayload | 0; - this._skipUTF8Validation = !!options.skipUTF8Validation; - this[kWebSocket$2] = undefined; - - this._bufferedBytes = 0; - this._buffers = []; - - this._compressed = false; - this._payloadLength = 0; - this._mask = undefined; - this._fragmented = 0; - this._masked = false; - this._fin = false; - this._opcode = 0; - - this._totalPayloadLength = 0; - this._messageLength = 0; - this._fragments = []; - - this._errored = false; - this._loop = false; - this._state = GET_INFO; - } - - /** - * Implements `Writable.prototype._write()`. - * - * @param {Buffer} chunk The chunk of data to write - * @param {String} encoding The character encoding of `chunk` - * @param {Function} cb Callback - * @private - */ - _write(chunk, encoding, cb) { - if (this._opcode === 0x08 && this._state == GET_INFO) return cb(); - - this._bufferedBytes += chunk.length; - this._buffers.push(chunk); - this.startLoop(cb); - } - - /** - * Consumes `n` bytes from the buffered data. - * - * @param {Number} n The number of bytes to consume - * @return {Buffer} The consumed bytes - * @private - */ - consume(n) { - this._bufferedBytes -= n; - - if (n === this._buffers[0].length) return this._buffers.shift(); - - if (n < this._buffers[0].length) { - const buf = this._buffers[0]; - this._buffers[0] = new FastBuffer( - buf.buffer, - buf.byteOffset + n, - buf.length - n - ); - - return new FastBuffer(buf.buffer, buf.byteOffset, n); - } - - const dst = Buffer.allocUnsafe(n); - - do { - const buf = this._buffers[0]; - const offset = dst.length - n; - - if (n >= buf.length) { - dst.set(this._buffers.shift(), offset); - } else { - dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset); - this._buffers[0] = new FastBuffer( - buf.buffer, - buf.byteOffset + n, - buf.length - n - ); - } - - n -= buf.length; - } while (n > 0); - - return dst; - } - - /** - * Starts the parsing loop. - * - * @param {Function} cb Callback - * @private - */ - startLoop(cb) { - this._loop = true; - - do { - switch (this._state) { - case GET_INFO: - this.getInfo(cb); - break; - case GET_PAYLOAD_LENGTH_16: - this.getPayloadLength16(cb); - break; - case GET_PAYLOAD_LENGTH_64: - this.getPayloadLength64(cb); - break; - case GET_MASK: - this.getMask(); - break; - case GET_DATA: - this.getData(cb); - break; - case INFLATING: - case DEFER_EVENT: - this._loop = false; - return; - } - } while (this._loop); - - if (!this._errored) cb(); - } - - /** - * Reads the first two bytes of a frame. - * - * @param {Function} cb Callback - * @private - */ - getInfo(cb) { - if (this._bufferedBytes < 2) { - this._loop = false; - return; - } - - const buf = this.consume(2); - - if ((buf[0] & 0x30) !== 0x00) { - const error = this.createError( - RangeError, - 'RSV2 and RSV3 must be clear', - true, - 1002, - 'WS_ERR_UNEXPECTED_RSV_2_3' - ); - - cb(error); - return; - } - - const compressed = (buf[0] & 0x40) === 0x40; - - if (compressed && !this._extensions[PerMessageDeflate$2.extensionName]) { - const error = this.createError( - RangeError, - 'RSV1 must be clear', - true, - 1002, - 'WS_ERR_UNEXPECTED_RSV_1' - ); - - cb(error); - return; - } - - this._fin = (buf[0] & 0x80) === 0x80; - this._opcode = buf[0] & 0x0f; - this._payloadLength = buf[1] & 0x7f; - - if (this._opcode === 0x00) { - if (compressed) { - const error = this.createError( - RangeError, - 'RSV1 must be clear', - true, - 1002, - 'WS_ERR_UNEXPECTED_RSV_1' - ); - - cb(error); - return; - } - - if (!this._fragmented) { - const error = this.createError( - RangeError, - 'invalid opcode 0', - true, - 1002, - 'WS_ERR_INVALID_OPCODE' - ); - - cb(error); - return; - } - - this._opcode = this._fragmented; - } else if (this._opcode === 0x01 || this._opcode === 0x02) { - if (this._fragmented) { - const error = this.createError( - RangeError, - `invalid opcode ${this._opcode}`, - true, - 1002, - 'WS_ERR_INVALID_OPCODE' - ); - - cb(error); - return; - } - - this._compressed = compressed; - } else if (this._opcode > 0x07 && this._opcode < 0x0b) { - if (!this._fin) { - const error = this.createError( - RangeError, - 'FIN must be set', - true, - 1002, - 'WS_ERR_EXPECTED_FIN' - ); - - cb(error); - return; - } - - if (compressed) { - const error = this.createError( - RangeError, - 'RSV1 must be clear', - true, - 1002, - 'WS_ERR_UNEXPECTED_RSV_1' - ); - - cb(error); - return; - } - - if ( - this._payloadLength > 0x7d || - (this._opcode === 0x08 && this._payloadLength === 1) - ) { - const error = this.createError( - RangeError, - `invalid payload length ${this._payloadLength}`, - true, - 1002, - 'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH' - ); - - cb(error); - return; - } - } else { - const error = this.createError( - RangeError, - `invalid opcode ${this._opcode}`, - true, - 1002, - 'WS_ERR_INVALID_OPCODE' - ); - - cb(error); - return; - } - - if (!this._fin && !this._fragmented) this._fragmented = this._opcode; - this._masked = (buf[1] & 0x80) === 0x80; - - if (this._isServer) { - if (!this._masked) { - const error = this.createError( - RangeError, - 'MASK must be set', - true, - 1002, - 'WS_ERR_EXPECTED_MASK' - ); - - cb(error); - return; - } - } else if (this._masked) { - const error = this.createError( - RangeError, - 'MASK must be clear', - true, - 1002, - 'WS_ERR_UNEXPECTED_MASK' - ); - - cb(error); - return; - } - - if (this._payloadLength === 126) this._state = GET_PAYLOAD_LENGTH_16; - else if (this._payloadLength === 127) this._state = GET_PAYLOAD_LENGTH_64; - else this.haveLength(cb); - } - - /** - * Gets extended payload length (7+16). - * - * @param {Function} cb Callback - * @private - */ - getPayloadLength16(cb) { - if (this._bufferedBytes < 2) { - this._loop = false; - return; - } - - this._payloadLength = this.consume(2).readUInt16BE(0); - this.haveLength(cb); - } - - /** - * Gets extended payload length (7+64). - * - * @param {Function} cb Callback - * @private - */ - getPayloadLength64(cb) { - if (this._bufferedBytes < 8) { - this._loop = false; - return; - } - - const buf = this.consume(8); - const num = buf.readUInt32BE(0); - - // - // The maximum safe integer in JavaScript is 2^53 - 1. An error is returned - // if payload length is greater than this number. - // - if (num > Math.pow(2, 53 - 32) - 1) { - const error = this.createError( - RangeError, - 'Unsupported WebSocket frame: payload length > 2^53 - 1', - false, - 1009, - 'WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH' - ); - - cb(error); - return; - } - - this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4); - this.haveLength(cb); - } - - /** - * Payload length has been read. - * - * @param {Function} cb Callback - * @private - */ - haveLength(cb) { - if (this._payloadLength && this._opcode < 0x08) { - this._totalPayloadLength += this._payloadLength; - if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) { - const error = this.createError( - RangeError, - 'Max payload size exceeded', - false, - 1009, - 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH' - ); - - cb(error); - return; - } - } - - if (this._masked) this._state = GET_MASK; - else this._state = GET_DATA; - } - - /** - * Reads mask bytes. - * - * @private - */ - getMask() { - if (this._bufferedBytes < 4) { - this._loop = false; - return; - } - - this._mask = this.consume(4); - this._state = GET_DATA; - } - - /** - * Reads data bytes. - * - * @param {Function} cb Callback - * @private - */ - getData(cb) { - let data = EMPTY_BUFFER$2; - - if (this._payloadLength) { - if (this._bufferedBytes < this._payloadLength) { - this._loop = false; - return; - } - - data = this.consume(this._payloadLength); - - if ( - this._masked && - (this._mask[0] | this._mask[1] | this._mask[2] | this._mask[3]) !== 0 - ) { - unmask(data, this._mask); - } - } - - if (this._opcode > 0x07) { - this.controlMessage(data, cb); - return; - } - - if (this._compressed) { - this._state = INFLATING; - this.decompress(data, cb); - return; - } - - if (data.length) { - // - // This message is not compressed so its length is the sum of the payload - // length of all fragments. - // - this._messageLength = this._totalPayloadLength; - this._fragments.push(data); - } - - this.dataMessage(cb); - } - - /** - * Decompresses data. - * - * @param {Buffer} data Compressed data - * @param {Function} cb Callback - * @private - */ - decompress(data, cb) { - const perMessageDeflate = this._extensions[PerMessageDeflate$2.extensionName]; - - perMessageDeflate.decompress(data, this._fin, (err, buf) => { - if (err) return cb(err); - - if (buf.length) { - this._messageLength += buf.length; - if (this._messageLength > this._maxPayload && this._maxPayload > 0) { - const error = this.createError( - RangeError, - 'Max payload size exceeded', - false, - 1009, - 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH' - ); - - cb(error); - return; - } - - this._fragments.push(buf); - } - - this.dataMessage(cb); - if (this._state === GET_INFO) this.startLoop(cb); - }); - } - - /** - * Handles a data message. - * - * @param {Function} cb Callback - * @private - */ - dataMessage(cb) { - if (!this._fin) { - this._state = GET_INFO; - return; - } - - const messageLength = this._messageLength; - const fragments = this._fragments; - - this._totalPayloadLength = 0; - this._messageLength = 0; - this._fragmented = 0; - this._fragments = []; - - if (this._opcode === 2) { - let data; - - if (this._binaryType === 'nodebuffer') { - data = concat(fragments, messageLength); - } else if (this._binaryType === 'arraybuffer') { - data = toArrayBuffer(concat(fragments, messageLength)); - } else if (this._binaryType === 'blob') { - data = new Blob(fragments); - } else { - data = fragments; - } - - if (this._allowSynchronousEvents) { - this.emit('message', data, true); - this._state = GET_INFO; - } else { - this._state = DEFER_EVENT; - setImmediate(() => { - this.emit('message', data, true); - this._state = GET_INFO; - this.startLoop(cb); - }); - } - } else { - const buf = concat(fragments, messageLength); - - if (!this._skipUTF8Validation && !isValidUTF8(buf)) { - const error = this.createError( - Error, - 'invalid UTF-8 sequence', - true, - 1007, - 'WS_ERR_INVALID_UTF8' - ); - - cb(error); - return; - } - - if (this._state === INFLATING || this._allowSynchronousEvents) { - this.emit('message', buf, false); - this._state = GET_INFO; - } else { - this._state = DEFER_EVENT; - setImmediate(() => { - this.emit('message', buf, false); - this._state = GET_INFO; - this.startLoop(cb); - }); - } - } - } - - /** - * Handles a control message. - * - * @param {Buffer} data Data to handle - * @return {(Error|RangeError|undefined)} A possible error - * @private - */ - controlMessage(data, cb) { - if (this._opcode === 0x08) { - if (data.length === 0) { - this._loop = false; - this.emit('conclude', 1005, EMPTY_BUFFER$2); - this.end(); - } else { - const code = data.readUInt16BE(0); - - if (!isValidStatusCode$1(code)) { - const error = this.createError( - RangeError, - `invalid status code ${code}`, - true, - 1002, - 'WS_ERR_INVALID_CLOSE_CODE' - ); - - cb(error); - return; - } - - const buf = new FastBuffer( - data.buffer, - data.byteOffset + 2, - data.length - 2 - ); - - if (!this._skipUTF8Validation && !isValidUTF8(buf)) { - const error = this.createError( - Error, - 'invalid UTF-8 sequence', - true, - 1007, - 'WS_ERR_INVALID_UTF8' - ); - - cb(error); - return; - } - - this._loop = false; - this.emit('conclude', code, buf); - this.end(); - } - - this._state = GET_INFO; - return; - } - - if (this._allowSynchronousEvents) { - this.emit(this._opcode === 0x09 ? 'ping' : 'pong', data); - this._state = GET_INFO; - } else { - this._state = DEFER_EVENT; - setImmediate(() => { - this.emit(this._opcode === 0x09 ? 'ping' : 'pong', data); - this._state = GET_INFO; - this.startLoop(cb); - }); - } - } - - /** - * Builds an error object. - * - * @param {function(new:Error|RangeError)} ErrorCtor The error constructor - * @param {String} message The error message - * @param {Boolean} prefix Specifies whether or not to add a default prefix to - * `message` - * @param {Number} statusCode The status code - * @param {String} errorCode The exposed error code - * @return {(Error|RangeError)} The error - * @private - */ - createError(ErrorCtor, message, prefix, statusCode, errorCode) { - this._loop = false; - this._errored = true; - - const err = new ErrorCtor( - prefix ? `Invalid WebSocket frame: ${message}` : message - ); - - Error.captureStackTrace(err, this.createError); - err.code = errorCode; - err[kStatusCode$1] = statusCode; - return err; - } -}; - -var receiver = Receiver$1; - -/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex" }] */ -const { randomFillSync } = require$$1$1; - -const PerMessageDeflate$1 = permessageDeflate; -const { EMPTY_BUFFER: EMPTY_BUFFER$1, kWebSocket: kWebSocket$1, NOOP: NOOP$1 } = constants; -const { isBlob: isBlob$1, isValidStatusCode } = validationExports; -const { mask: applyMask, toBuffer: toBuffer$1 } = bufferUtilExports; - -const kByteLength = Symbol('kByteLength'); -const maskBuffer = Buffer.alloc(4); -const RANDOM_POOL_SIZE = 8 * 1024; -let randomPool; -let randomPoolPointer = RANDOM_POOL_SIZE; - -const DEFAULT = 0; -const DEFLATING = 1; -const GET_BLOB_DATA = 2; - -/** - * HyBi Sender implementation. - */ -let Sender$1 = class Sender { - /** - * Creates a Sender instance. - * - * @param {Duplex} socket The connection socket - * @param {Object} [extensions] An object containing the negotiated extensions - * @param {Function} [generateMask] The function used to generate the masking - * key - */ - constructor(socket, extensions, generateMask) { - this._extensions = extensions || {}; - - if (generateMask) { - this._generateMask = generateMask; - this._maskBuffer = Buffer.alloc(4); - } - - this._socket = socket; - - this._firstFragment = true; - this._compress = false; - - this._bufferedBytes = 0; - this._queue = []; - this._state = DEFAULT; - this.onerror = NOOP$1; - this[kWebSocket$1] = undefined; - } - - /** - * Frames a piece of data according to the HyBi WebSocket protocol. - * - * @param {(Buffer|String)} data The data to frame - * @param {Object} options Options object - * @param {Boolean} [options.fin=false] Specifies whether or not to set the - * FIN bit - * @param {Function} [options.generateMask] The function used to generate the - * masking key - * @param {Boolean} [options.mask=false] Specifies whether or not to mask - * `data` - * @param {Buffer} [options.maskBuffer] The buffer used to store the masking - * key - * @param {Number} options.opcode The opcode - * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be - * modified - * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the - * RSV1 bit - * @return {(Buffer|String)[]} The framed data - * @public - */ - static frame(data, options) { - let mask; - let merge = false; - let offset = 2; - let skipMasking = false; - - if (options.mask) { - mask = options.maskBuffer || maskBuffer; - - if (options.generateMask) { - options.generateMask(mask); - } else { - if (randomPoolPointer === RANDOM_POOL_SIZE) { - /* istanbul ignore else */ - if (randomPool === undefined) { - // - // This is lazily initialized because server-sent frames must not - // be masked so it may never be used. - // - randomPool = Buffer.alloc(RANDOM_POOL_SIZE); - } - - randomFillSync(randomPool, 0, RANDOM_POOL_SIZE); - randomPoolPointer = 0; - } - - mask[0] = randomPool[randomPoolPointer++]; - mask[1] = randomPool[randomPoolPointer++]; - mask[2] = randomPool[randomPoolPointer++]; - mask[3] = randomPool[randomPoolPointer++]; - } - - skipMasking = (mask[0] | mask[1] | mask[2] | mask[3]) === 0; - offset = 6; - } - - let dataLength; - - if (typeof data === 'string') { - if ( - (!options.mask || skipMasking) && - options[kByteLength] !== undefined - ) { - dataLength = options[kByteLength]; - } else { - data = Buffer.from(data); - dataLength = data.length; - } - } else { - dataLength = data.length; - merge = options.mask && options.readOnly && !skipMasking; - } - - let payloadLength = dataLength; - - if (dataLength >= 65536) { - offset += 8; - payloadLength = 127; - } else if (dataLength > 125) { - offset += 2; - payloadLength = 126; - } - - const target = Buffer.allocUnsafe(merge ? dataLength + offset : offset); - - target[0] = options.fin ? options.opcode | 0x80 : options.opcode; - if (options.rsv1) target[0] |= 0x40; - - target[1] = payloadLength; - - if (payloadLength === 126) { - target.writeUInt16BE(dataLength, 2); - } else if (payloadLength === 127) { - target[2] = target[3] = 0; - target.writeUIntBE(dataLength, 4, 6); - } - - if (!options.mask) return [target, data]; - - target[1] |= 0x80; - target[offset - 4] = mask[0]; - target[offset - 3] = mask[1]; - target[offset - 2] = mask[2]; - target[offset - 1] = mask[3]; - - if (skipMasking) return [target, data]; - - if (merge) { - applyMask(data, mask, target, offset, dataLength); - return [target]; - } - - applyMask(data, mask, data, 0, dataLength); - return [target, data]; - } - - /** - * Sends a close message to the other peer. - * - * @param {Number} [code] The status code component of the body - * @param {(String|Buffer)} [data] The message component of the body - * @param {Boolean} [mask=false] Specifies whether or not to mask the message - * @param {Function} [cb] Callback - * @public - */ - close(code, data, mask, cb) { - let buf; - - if (code === undefined) { - buf = EMPTY_BUFFER$1; - } else if (typeof code !== 'number' || !isValidStatusCode(code)) { - throw new TypeError('First argument must be a valid error code number'); - } else if (data === undefined || !data.length) { - buf = Buffer.allocUnsafe(2); - buf.writeUInt16BE(code, 0); - } else { - const length = Buffer.byteLength(data); - - if (length > 123) { - throw new RangeError('The message must not be greater than 123 bytes'); - } - - buf = Buffer.allocUnsafe(2 + length); - buf.writeUInt16BE(code, 0); - - if (typeof data === 'string') { - buf.write(data, 2); - } else { - buf.set(data, 2); - } - } - - const options = { - [kByteLength]: buf.length, - fin: true, - generateMask: this._generateMask, - mask, - maskBuffer: this._maskBuffer, - opcode: 0x08, - readOnly: false, - rsv1: false - }; - - if (this._state !== DEFAULT) { - this.enqueue([this.dispatch, buf, false, options, cb]); - } else { - this.sendFrame(Sender.frame(buf, options), cb); - } - } - - /** - * Sends a ping message to the other peer. - * - * @param {*} data The message to send - * @param {Boolean} [mask=false] Specifies whether or not to mask `data` - * @param {Function} [cb] Callback - * @public - */ - ping(data, mask, cb) { - let byteLength; - let readOnly; - - if (typeof data === 'string') { - byteLength = Buffer.byteLength(data); - readOnly = false; - } else if (isBlob$1(data)) { - byteLength = data.size; - readOnly = false; - } else { - data = toBuffer$1(data); - byteLength = data.length; - readOnly = toBuffer$1.readOnly; - } - - if (byteLength > 125) { - throw new RangeError('The data size must not be greater than 125 bytes'); - } - - const options = { - [kByteLength]: byteLength, - fin: true, - generateMask: this._generateMask, - mask, - maskBuffer: this._maskBuffer, - opcode: 0x09, - readOnly, - rsv1: false - }; - - if (isBlob$1(data)) { - if (this._state !== DEFAULT) { - this.enqueue([this.getBlobData, data, false, options, cb]); - } else { - this.getBlobData(data, false, options, cb); - } - } else if (this._state !== DEFAULT) { - this.enqueue([this.dispatch, data, false, options, cb]); - } else { - this.sendFrame(Sender.frame(data, options), cb); - } - } - - /** - * Sends a pong message to the other peer. - * - * @param {*} data The message to send - * @param {Boolean} [mask=false] Specifies whether or not to mask `data` - * @param {Function} [cb] Callback - * @public - */ - pong(data, mask, cb) { - let byteLength; - let readOnly; - - if (typeof data === 'string') { - byteLength = Buffer.byteLength(data); - readOnly = false; - } else if (isBlob$1(data)) { - byteLength = data.size; - readOnly = false; - } else { - data = toBuffer$1(data); - byteLength = data.length; - readOnly = toBuffer$1.readOnly; - } - - if (byteLength > 125) { - throw new RangeError('The data size must not be greater than 125 bytes'); - } - - const options = { - [kByteLength]: byteLength, - fin: true, - generateMask: this._generateMask, - mask, - maskBuffer: this._maskBuffer, - opcode: 0x0a, - readOnly, - rsv1: false - }; - - if (isBlob$1(data)) { - if (this._state !== DEFAULT) { - this.enqueue([this.getBlobData, data, false, options, cb]); - } else { - this.getBlobData(data, false, options, cb); - } - } else if (this._state !== DEFAULT) { - this.enqueue([this.dispatch, data, false, options, cb]); - } else { - this.sendFrame(Sender.frame(data, options), cb); - } - } - - /** - * Sends a data message to the other peer. - * - * @param {*} data The message to send - * @param {Object} options Options object - * @param {Boolean} [options.binary=false] Specifies whether `data` is binary - * or text - * @param {Boolean} [options.compress=false] Specifies whether or not to - * compress `data` - * @param {Boolean} [options.fin=false] Specifies whether the fragment is the - * last one - * @param {Boolean} [options.mask=false] Specifies whether or not to mask - * `data` - * @param {Function} [cb] Callback - * @public - */ - send(data, options, cb) { - const perMessageDeflate = this._extensions[PerMessageDeflate$1.extensionName]; - let opcode = options.binary ? 2 : 1; - let rsv1 = options.compress; - - let byteLength; - let readOnly; - - if (typeof data === 'string') { - byteLength = Buffer.byteLength(data); - readOnly = false; - } else if (isBlob$1(data)) { - byteLength = data.size; - readOnly = false; - } else { - data = toBuffer$1(data); - byteLength = data.length; - readOnly = toBuffer$1.readOnly; - } - - if (this._firstFragment) { - this._firstFragment = false; - if ( - rsv1 && - perMessageDeflate && - perMessageDeflate.params[ - perMessageDeflate._isServer - ? 'server_no_context_takeover' - : 'client_no_context_takeover' - ] - ) { - rsv1 = byteLength >= perMessageDeflate._threshold; - } - this._compress = rsv1; - } else { - rsv1 = false; - opcode = 0; - } - - if (options.fin) this._firstFragment = true; - - const opts = { - [kByteLength]: byteLength, - fin: options.fin, - generateMask: this._generateMask, - mask: options.mask, - maskBuffer: this._maskBuffer, - opcode, - readOnly, - rsv1 - }; - - if (isBlob$1(data)) { - if (this._state !== DEFAULT) { - this.enqueue([this.getBlobData, data, this._compress, opts, cb]); - } else { - this.getBlobData(data, this._compress, opts, cb); - } - } else if (this._state !== DEFAULT) { - this.enqueue([this.dispatch, data, this._compress, opts, cb]); - } else { - this.dispatch(data, this._compress, opts, cb); - } - } - - /** - * Gets the contents of a blob as binary data. - * - * @param {Blob} blob The blob - * @param {Boolean} [compress=false] Specifies whether or not to compress - * the data - * @param {Object} options Options object - * @param {Boolean} [options.fin=false] Specifies whether or not to set the - * FIN bit - * @param {Function} [options.generateMask] The function used to generate the - * masking key - * @param {Boolean} [options.mask=false] Specifies whether or not to mask - * `data` - * @param {Buffer} [options.maskBuffer] The buffer used to store the masking - * key - * @param {Number} options.opcode The opcode - * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be - * modified - * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the - * RSV1 bit - * @param {Function} [cb] Callback - * @private - */ - getBlobData(blob, compress, options, cb) { - this._bufferedBytes += options[kByteLength]; - this._state = GET_BLOB_DATA; - - blob - .arrayBuffer() - .then((arrayBuffer) => { - if (this._socket.destroyed) { - const err = new Error( - 'The socket was closed while the blob was being read' - ); - - // - // `callCallbacks` is called in the next tick to ensure that errors - // that might be thrown in the callbacks behave like errors thrown - // outside the promise chain. - // - process.nextTick(callCallbacks, this, err, cb); - return; - } - - this._bufferedBytes -= options[kByteLength]; - const data = toBuffer$1(arrayBuffer); - - if (!compress) { - this._state = DEFAULT; - this.sendFrame(Sender.frame(data, options), cb); - this.dequeue(); - } else { - this.dispatch(data, compress, options, cb); - } - }) - .catch((err) => { - // - // `onError` is called in the next tick for the same reason that - // `callCallbacks` above is. - // - process.nextTick(onError, this, err, cb); - }); - } - - /** - * Dispatches a message. - * - * @param {(Buffer|String)} data The message to send - * @param {Boolean} [compress=false] Specifies whether or not to compress - * `data` - * @param {Object} options Options object - * @param {Boolean} [options.fin=false] Specifies whether or not to set the - * FIN bit - * @param {Function} [options.generateMask] The function used to generate the - * masking key - * @param {Boolean} [options.mask=false] Specifies whether or not to mask - * `data` - * @param {Buffer} [options.maskBuffer] The buffer used to store the masking - * key - * @param {Number} options.opcode The opcode - * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be - * modified - * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the - * RSV1 bit - * @param {Function} [cb] Callback - * @private - */ - dispatch(data, compress, options, cb) { - if (!compress) { - this.sendFrame(Sender.frame(data, options), cb); - return; - } - - const perMessageDeflate = this._extensions[PerMessageDeflate$1.extensionName]; - - this._bufferedBytes += options[kByteLength]; - this._state = DEFLATING; - perMessageDeflate.compress(data, options.fin, (_, buf) => { - if (this._socket.destroyed) { - const err = new Error( - 'The socket was closed while data was being compressed' - ); - - callCallbacks(this, err, cb); - return; - } - - this._bufferedBytes -= options[kByteLength]; - this._state = DEFAULT; - options.readOnly = false; - this.sendFrame(Sender.frame(buf, options), cb); - this.dequeue(); - }); - } - - /** - * Executes queued send operations. - * - * @private - */ - dequeue() { - while (this._state === DEFAULT && this._queue.length) { - const params = this._queue.shift(); - - this._bufferedBytes -= params[3][kByteLength]; - Reflect.apply(params[0], this, params.slice(1)); - } - } - - /** - * Enqueues a send operation. - * - * @param {Array} params Send operation parameters. - * @private - */ - enqueue(params) { - this._bufferedBytes += params[3][kByteLength]; - this._queue.push(params); - } - - /** - * Sends a frame. - * - * @param {Buffer[]} list The frame to send - * @param {Function} [cb] Callback - * @private - */ - sendFrame(list, cb) { - if (list.length === 2) { - this._socket.cork(); - this._socket.write(list[0]); - this._socket.write(list[1], cb); - this._socket.uncork(); - } else { - this._socket.write(list[0], cb); - } - } -}; - -var sender = Sender$1; - -/** - * Calls queued callbacks with an error. - * - * @param {Sender} sender The `Sender` instance - * @param {Error} err The error to call the callbacks with - * @param {Function} [cb] The first callback - * @private - */ -function callCallbacks(sender, err, cb) { - if (typeof cb === 'function') cb(err); - - for (let i = 0; i < sender._queue.length; i++) { - const params = sender._queue[i]; - const callback = params[params.length - 1]; - - if (typeof callback === 'function') callback(err); - } -} - -/** - * Handles a `Sender` error. - * - * @param {Sender} sender The `Sender` instance - * @param {Error} err The error - * @param {Function} [cb] The first pending callback - * @private - */ -function onError(sender, err, cb) { - callCallbacks(sender, err, cb); - sender.onerror(err); -} - -const { kForOnEventAttribute: kForOnEventAttribute$1, kListener: kListener$1 } = constants; - -const kCode = Symbol('kCode'); -const kData = Symbol('kData'); -const kError = Symbol('kError'); -const kMessage = Symbol('kMessage'); -const kReason = Symbol('kReason'); -const kTarget = Symbol('kTarget'); -const kType = Symbol('kType'); -const kWasClean = Symbol('kWasClean'); - -/** - * Class representing an event. - */ -class Event { - /** - * Create a new `Event`. - * - * @param {String} type The name of the event - * @throws {TypeError} If the `type` argument is not specified - */ - constructor(type) { - this[kTarget] = null; - this[kType] = type; - } - - /** - * @type {*} - */ - get target() { - return this[kTarget]; - } - - /** - * @type {String} - */ - get type() { - return this[kType]; - } -} - -Object.defineProperty(Event.prototype, 'target', { enumerable: true }); -Object.defineProperty(Event.prototype, 'type', { enumerable: true }); - -/** - * Class representing a close event. - * - * @extends Event - */ -class CloseEvent extends Event { - /** - * Create a new `CloseEvent`. - * - * @param {String} type The name of the event - * @param {Object} [options] A dictionary object that allows for setting - * attributes via object members of the same name - * @param {Number} [options.code=0] The status code explaining why the - * connection was closed - * @param {String} [options.reason=''] A human-readable string explaining why - * the connection was closed - * @param {Boolean} [options.wasClean=false] Indicates whether or not the - * connection was cleanly closed - */ - constructor(type, options = {}) { - super(type); - - this[kCode] = options.code === undefined ? 0 : options.code; - this[kReason] = options.reason === undefined ? '' : options.reason; - this[kWasClean] = options.wasClean === undefined ? false : options.wasClean; - } - - /** - * @type {Number} - */ - get code() { - return this[kCode]; - } - - /** - * @type {String} - */ - get reason() { - return this[kReason]; - } - - /** - * @type {Boolean} - */ - get wasClean() { - return this[kWasClean]; - } -} - -Object.defineProperty(CloseEvent.prototype, 'code', { enumerable: true }); -Object.defineProperty(CloseEvent.prototype, 'reason', { enumerable: true }); -Object.defineProperty(CloseEvent.prototype, 'wasClean', { enumerable: true }); - -/** - * Class representing an error event. - * - * @extends Event - */ -class ErrorEvent extends Event { - /** - * Create a new `ErrorEvent`. - * - * @param {String} type The name of the event - * @param {Object} [options] A dictionary object that allows for setting - * attributes via object members of the same name - * @param {*} [options.error=null] The error that generated this event - * @param {String} [options.message=''] The error message - */ - constructor(type, options = {}) { - super(type); - - this[kError] = options.error === undefined ? null : options.error; - this[kMessage] = options.message === undefined ? '' : options.message; - } - - /** - * @type {*} - */ - get error() { - return this[kError]; - } - - /** - * @type {String} - */ - get message() { - return this[kMessage]; - } -} - -Object.defineProperty(ErrorEvent.prototype, 'error', { enumerable: true }); -Object.defineProperty(ErrorEvent.prototype, 'message', { enumerable: true }); - -/** - * Class representing a message event. - * - * @extends Event - */ -class MessageEvent extends Event { - /** - * Create a new `MessageEvent`. - * - * @param {String} type The name of the event - * @param {Object} [options] A dictionary object that allows for setting - * attributes via object members of the same name - * @param {*} [options.data=null] The message content - */ - constructor(type, options = {}) { - super(type); - - this[kData] = options.data === undefined ? null : options.data; - } - - /** - * @type {*} - */ - get data() { - return this[kData]; - } -} - -Object.defineProperty(MessageEvent.prototype, 'data', { enumerable: true }); - -/** - * This provides methods for emulating the `EventTarget` interface. It's not - * meant to be used directly. - * - * @mixin - */ -const EventTarget = { - /** - * Register an event listener. - * - * @param {String} type A string representing the event type to listen for - * @param {(Function|Object)} handler The listener to add - * @param {Object} [options] An options object specifies characteristics about - * the event listener - * @param {Boolean} [options.once=false] A `Boolean` indicating that the - * listener should be invoked at most once after being added. If `true`, - * the listener would be automatically removed when invoked. - * @public - */ - addEventListener(type, handler, options = {}) { - for (const listener of this.listeners(type)) { - if ( - !options[kForOnEventAttribute$1] && - listener[kListener$1] === handler && - !listener[kForOnEventAttribute$1] - ) { - return; - } - } - - let wrapper; - - if (type === 'message') { - wrapper = function onMessage(data, isBinary) { - const event = new MessageEvent('message', { - data: isBinary ? data : data.toString() - }); - - event[kTarget] = this; - callListener(handler, this, event); - }; - } else if (type === 'close') { - wrapper = function onClose(code, message) { - const event = new CloseEvent('close', { - code, - reason: message.toString(), - wasClean: this._closeFrameReceived && this._closeFrameSent - }); - - event[kTarget] = this; - callListener(handler, this, event); - }; - } else if (type === 'error') { - wrapper = function onError(error) { - const event = new ErrorEvent('error', { - error, - message: error.message - }); - - event[kTarget] = this; - callListener(handler, this, event); - }; - } else if (type === 'open') { - wrapper = function onOpen() { - const event = new Event('open'); - - event[kTarget] = this; - callListener(handler, this, event); - }; - } else { - return; - } - - wrapper[kForOnEventAttribute$1] = !!options[kForOnEventAttribute$1]; - wrapper[kListener$1] = handler; - - if (options.once) { - this.once(type, wrapper); - } else { - this.on(type, wrapper); - } - }, - - /** - * Remove an event listener. - * - * @param {String} type A string representing the event type to remove - * @param {(Function|Object)} handler The listener to remove - * @public - */ - removeEventListener(type, handler) { - for (const listener of this.listeners(type)) { - if (listener[kListener$1] === handler && !listener[kForOnEventAttribute$1]) { - this.removeListener(type, listener); - break; - } - } - } -}; - -var eventTarget = { - CloseEvent, - ErrorEvent, - Event, - EventTarget, - MessageEvent -}; - -/** - * Call an event listener - * - * @param {(Function|Object)} listener The listener to call - * @param {*} thisArg The value to use as `this`` when calling the listener - * @param {Event} event The event to pass to the listener - * @private - */ -function callListener(listener, thisArg, event) { - if (typeof listener === 'object' && listener.handleEvent) { - listener.handleEvent.call(listener, event); - } else { - listener.call(thisArg, event); - } -} - -const { tokenChars } = validationExports; - -/** - * Adds an offer to the map of extension offers or a parameter to the map of - * parameters. - * - * @param {Object} dest The map of extension offers or parameters - * @param {String} name The extension or parameter name - * @param {(Object|Boolean|String)} elem The extension parameters or the - * parameter value - * @private - */ -function push(dest, name, elem) { - if (dest[name] === undefined) dest[name] = [elem]; - else dest[name].push(elem); -} - -/** - * Parses the `Sec-WebSocket-Extensions` header into an object. - * - * @param {String} header The field value of the header - * @return {Object} The parsed object - * @public - */ -function parse$1(header) { - const offers = Object.create(null); - let params = Object.create(null); - let mustUnescape = false; - let isEscaping = false; - let inQuotes = false; - let extensionName; - let paramName; - let start = -1; - let code = -1; - let end = -1; - let i = 0; - - for (; i < header.length; i++) { - code = header.charCodeAt(i); - - if (extensionName === undefined) { - if (end === -1 && tokenChars[code] === 1) { - if (start === -1) start = i; - } else if ( - i !== 0 && - (code === 0x20 /* ' ' */ || code === 0x09) /* '\t' */ - ) { - if (end === -1 && start !== -1) end = i; - } else if (code === 0x3b /* ';' */ || code === 0x2c /* ',' */) { - if (start === -1) { - throw new SyntaxError(`Unexpected character at index ${i}`); - } - - if (end === -1) end = i; - const name = header.slice(start, end); - if (code === 0x2c) { - push(offers, name, params); - params = Object.create(null); - } else { - extensionName = name; - } - - start = end = -1; - } else { - throw new SyntaxError(`Unexpected character at index ${i}`); - } - } else if (paramName === undefined) { - if (end === -1 && tokenChars[code] === 1) { - if (start === -1) start = i; - } else if (code === 0x20 || code === 0x09) { - if (end === -1 && start !== -1) end = i; - } else if (code === 0x3b || code === 0x2c) { - if (start === -1) { - throw new SyntaxError(`Unexpected character at index ${i}`); - } - - if (end === -1) end = i; - push(params, header.slice(start, end), true); - if (code === 0x2c) { - push(offers, extensionName, params); - params = Object.create(null); - extensionName = undefined; - } - - start = end = -1; - } else if (code === 0x3d /* '=' */ && start !== -1 && end === -1) { - paramName = header.slice(start, i); - start = end = -1; - } else { - throw new SyntaxError(`Unexpected character at index ${i}`); - } - } else { - // - // The value of a quoted-string after unescaping must conform to the - // token ABNF, so only token characters are valid. - // Ref: https://tools.ietf.org/html/rfc6455#section-9.1 - // - if (isEscaping) { - if (tokenChars[code] !== 1) { - throw new SyntaxError(`Unexpected character at index ${i}`); - } - if (start === -1) start = i; - else if (!mustUnescape) mustUnescape = true; - isEscaping = false; - } else if (inQuotes) { - if (tokenChars[code] === 1) { - if (start === -1) start = i; - } else if (code === 0x22 /* '"' */ && start !== -1) { - inQuotes = false; - end = i; - } else if (code === 0x5c /* '\' */) { - isEscaping = true; - } else { - throw new SyntaxError(`Unexpected character at index ${i}`); - } - } else if (code === 0x22 && header.charCodeAt(i - 1) === 0x3d) { - inQuotes = true; - } else if (end === -1 && tokenChars[code] === 1) { - if (start === -1) start = i; - } else if (start !== -1 && (code === 0x20 || code === 0x09)) { - if (end === -1) end = i; - } else if (code === 0x3b || code === 0x2c) { - if (start === -1) { - throw new SyntaxError(`Unexpected character at index ${i}`); - } - - if (end === -1) end = i; - let value = header.slice(start, end); - if (mustUnescape) { - value = value.replace(/\\/g, ''); - mustUnescape = false; - } - push(params, paramName, value); - if (code === 0x2c) { - push(offers, extensionName, params); - params = Object.create(null); - extensionName = undefined; - } - - paramName = undefined; - start = end = -1; - } else { - throw new SyntaxError(`Unexpected character at index ${i}`); - } - } - } - - if (start === -1 || inQuotes || code === 0x20 || code === 0x09) { - throw new SyntaxError('Unexpected end of input'); - } - - if (end === -1) end = i; - const token = header.slice(start, end); - if (extensionName === undefined) { - push(offers, token, params); - } else { - if (paramName === undefined) { - push(params, token, true); - } else if (mustUnescape) { - push(params, paramName, token.replace(/\\/g, '')); - } else { - push(params, paramName, token); - } - push(offers, extensionName, params); - } - - return offers; -} - -/** - * Builds the `Sec-WebSocket-Extensions` header field value. - * - * @param {Object} extensions The map of extensions and parameters to format - * @return {String} A string representing the given object - * @public - */ -function format$1(extensions) { - return Object.keys(extensions) - .map((extension) => { - let configurations = extensions[extension]; - if (!Array.isArray(configurations)) configurations = [configurations]; - return configurations - .map((params) => { - return [extension] - .concat( - Object.keys(params).map((k) => { - let values = params[k]; - if (!Array.isArray(values)) values = [values]; - return values - .map((v) => (v === true ? k : `${k}=${v}`)) - .join('; '); - }) - ) - .join('; '); - }) - .join(', '); - }) - .join(', '); -} - -var extension = { format: format$1, parse: parse$1 }; - -/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex|Readable$", "caughtErrors": "none" }] */ - -const EventEmitter = require$$0$3; -const https = require$$1$2; -const http = require$$2$1; -const net = require$$3; -const tls = require$$4; -const { randomBytes, createHash } = require$$1$1; -const { URL } = require$$7; - -const PerMessageDeflate = permessageDeflate; -const Receiver = receiver; -const Sender = sender; -const { isBlob } = validationExports; - -const { - BINARY_TYPES, - EMPTY_BUFFER, - GUID, - kForOnEventAttribute, - kListener, - kStatusCode, - kWebSocket, - NOOP -} = constants; -const { - EventTarget: { addEventListener, removeEventListener } -} = eventTarget; -const { format, parse } = extension; -const { toBuffer } = bufferUtilExports; - -const closeTimeout = 30 * 1000; -const kAborted = Symbol('kAborted'); -const protocolVersions = [8, 13]; -const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED']; -const subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/; - -/** - * Class representing a WebSocket. - * - * @extends EventEmitter - */ -class WebSocket extends EventEmitter { - /** - * Create a new `WebSocket`. - * - * @param {(String|URL)} address The URL to which to connect - * @param {(String|String[])} [protocols] The subprotocols - * @param {Object} [options] Connection options - */ - constructor(address, protocols, options) { - super(); - - this._binaryType = BINARY_TYPES[0]; - this._closeCode = 1006; - this._closeFrameReceived = false; - this._closeFrameSent = false; - this._closeMessage = EMPTY_BUFFER; - this._closeTimer = null; - this._errorEmitted = false; - this._extensions = {}; - this._paused = false; - this._protocol = ''; - this._readyState = WebSocket.CONNECTING; - this._receiver = null; - this._sender = null; - this._socket = null; - - if (address !== null) { - this._bufferedAmount = 0; - this._isServer = false; - this._redirects = 0; - - if (protocols === undefined) { - protocols = []; - } else if (!Array.isArray(protocols)) { - if (typeof protocols === 'object' && protocols !== null) { - options = protocols; - protocols = []; - } else { - protocols = [protocols]; - } - } - - initAsClient(this, address, protocols, options); - } else { - this._autoPong = options.autoPong; - this._isServer = true; - } - } - - /** - * For historical reasons, the custom "nodebuffer" type is used by the default - * instead of "blob". - * - * @type {String} - */ - get binaryType() { - return this._binaryType; - } - - set binaryType(type) { - if (!BINARY_TYPES.includes(type)) return; - - this._binaryType = type; - - // - // Allow to change `binaryType` on the fly. - // - if (this._receiver) this._receiver._binaryType = type; - } - - /** - * @type {Number} - */ - get bufferedAmount() { - if (!this._socket) return this._bufferedAmount; - - return this._socket._writableState.length + this._sender._bufferedBytes; - } - - /** - * @type {String} - */ - get extensions() { - return Object.keys(this._extensions).join(); - } - - /** - * @type {Boolean} - */ - get isPaused() { - return this._paused; - } - - /** - * @type {Function} - */ - /* istanbul ignore next */ - get onclose() { - return null; - } - - /** - * @type {Function} - */ - /* istanbul ignore next */ - get onerror() { - return null; - } - - /** - * @type {Function} - */ - /* istanbul ignore next */ - get onopen() { - return null; - } - - /** - * @type {Function} - */ - /* istanbul ignore next */ - get onmessage() { - return null; - } - - /** - * @type {String} - */ - get protocol() { - return this._protocol; - } - - /** - * @type {Number} - */ - get readyState() { - return this._readyState; - } - - /** - * @type {String} - */ - get url() { - return this._url; - } - - /** - * Set up the socket and the internal resources. - * - * @param {Duplex} socket The network socket between the server and client - * @param {Buffer} head The first packet of the upgraded stream - * @param {Object} options Options object - * @param {Boolean} [options.allowSynchronousEvents=false] Specifies whether - * any of the `'message'`, `'ping'`, and `'pong'` events can be emitted - * multiple times in the same tick - * @param {Function} [options.generateMask] The function used to generate the - * masking key - * @param {Number} [options.maxPayload=0] The maximum allowed message size - * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or - * not to skip UTF-8 validation for text and close messages - * @private - */ - setSocket(socket, head, options) { - const receiver = new Receiver({ - allowSynchronousEvents: options.allowSynchronousEvents, - binaryType: this.binaryType, - extensions: this._extensions, - isServer: this._isServer, - maxPayload: options.maxPayload, - skipUTF8Validation: options.skipUTF8Validation - }); - - const sender = new Sender(socket, this._extensions, options.generateMask); - - this._receiver = receiver; - this._sender = sender; - this._socket = socket; - - receiver[kWebSocket] = this; - sender[kWebSocket] = this; - socket[kWebSocket] = this; - - receiver.on('conclude', receiverOnConclude); - receiver.on('drain', receiverOnDrain); - receiver.on('error', receiverOnError); - receiver.on('message', receiverOnMessage); - receiver.on('ping', receiverOnPing); - receiver.on('pong', receiverOnPong); - - sender.onerror = senderOnError; - - // - // These methods may not be available if `socket` is just a `Duplex`. - // - if (socket.setTimeout) socket.setTimeout(0); - if (socket.setNoDelay) socket.setNoDelay(); - - if (head.length > 0) socket.unshift(head); - - socket.on('close', socketOnClose); - socket.on('data', socketOnData); - socket.on('end', socketOnEnd); - socket.on('error', socketOnError); - - this._readyState = WebSocket.OPEN; - this.emit('open'); - } - - /** - * Emit the `'close'` event. - * - * @private - */ - emitClose() { - if (!this._socket) { - this._readyState = WebSocket.CLOSED; - this.emit('close', this._closeCode, this._closeMessage); - return; - } - - if (this._extensions[PerMessageDeflate.extensionName]) { - this._extensions[PerMessageDeflate.extensionName].cleanup(); - } - - this._receiver.removeAllListeners(); - this._readyState = WebSocket.CLOSED; - this.emit('close', this._closeCode, this._closeMessage); - } - - /** - * Start a closing handshake. - * - * +----------+ +-----------+ +----------+ - * - - -|ws.close()|-->|close frame|-->|ws.close()|- - - - * | +----------+ +-----------+ +----------+ | - * +----------+ +-----------+ | - * CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING - * +----------+ +-----------+ | - * | | | +---+ | - * +------------------------+-->|fin| - - - - - * | +---+ | +---+ - * - - - - -|fin|<---------------------+ - * +---+ - * - * @param {Number} [code] Status code explaining why the connection is closing - * @param {(String|Buffer)} [data] The reason why the connection is - * closing - * @public - */ - close(code, data) { - if (this.readyState === WebSocket.CLOSED) return; - if (this.readyState === WebSocket.CONNECTING) { - const msg = 'WebSocket was closed before the connection was established'; - abortHandshake(this, this._req, msg); - return; - } - - if (this.readyState === WebSocket.CLOSING) { - if ( - this._closeFrameSent && - (this._closeFrameReceived || this._receiver._writableState.errorEmitted) - ) { - this._socket.end(); - } - - return; - } - - this._readyState = WebSocket.CLOSING; - this._sender.close(code, data, !this._isServer, (err) => { - // - // This error is handled by the `'error'` listener on the socket. We only - // want to know if the close frame has been sent here. - // - if (err) return; - - this._closeFrameSent = true; - - if ( - this._closeFrameReceived || - this._receiver._writableState.errorEmitted - ) { - this._socket.end(); - } - }); - - setCloseTimer(this); - } - - /** - * Pause the socket. - * - * @public - */ - pause() { - if ( - this.readyState === WebSocket.CONNECTING || - this.readyState === WebSocket.CLOSED - ) { - return; - } - - this._paused = true; - this._socket.pause(); - } - - /** - * Send a ping. - * - * @param {*} [data] The data to send - * @param {Boolean} [mask] Indicates whether or not to mask `data` - * @param {Function} [cb] Callback which is executed when the ping is sent - * @public - */ - ping(data, mask, cb) { - if (this.readyState === WebSocket.CONNECTING) { - throw new Error('WebSocket is not open: readyState 0 (CONNECTING)'); - } - - if (typeof data === 'function') { - cb = data; - data = mask = undefined; - } else if (typeof mask === 'function') { - cb = mask; - mask = undefined; - } - - if (typeof data === 'number') data = data.toString(); - - if (this.readyState !== WebSocket.OPEN) { - sendAfterClose(this, data, cb); - return; - } - - if (mask === undefined) mask = !this._isServer; - this._sender.ping(data || EMPTY_BUFFER, mask, cb); - } - - /** - * Send a pong. - * - * @param {*} [data] The data to send - * @param {Boolean} [mask] Indicates whether or not to mask `data` - * @param {Function} [cb] Callback which is executed when the pong is sent - * @public - */ - pong(data, mask, cb) { - if (this.readyState === WebSocket.CONNECTING) { - throw new Error('WebSocket is not open: readyState 0 (CONNECTING)'); - } - - if (typeof data === 'function') { - cb = data; - data = mask = undefined; - } else if (typeof mask === 'function') { - cb = mask; - mask = undefined; - } - - if (typeof data === 'number') data = data.toString(); - - if (this.readyState !== WebSocket.OPEN) { - sendAfterClose(this, data, cb); - return; - } - - if (mask === undefined) mask = !this._isServer; - this._sender.pong(data || EMPTY_BUFFER, mask, cb); - } - - /** - * Resume the socket. - * - * @public - */ - resume() { - if ( - this.readyState === WebSocket.CONNECTING || - this.readyState === WebSocket.CLOSED - ) { - return; - } - - this._paused = false; - if (!this._receiver._writableState.needDrain) this._socket.resume(); - } - - /** - * Send a data message. - * - * @param {*} data The message to send - * @param {Object} [options] Options object - * @param {Boolean} [options.binary] Specifies whether `data` is binary or - * text - * @param {Boolean} [options.compress] Specifies whether or not to compress - * `data` - * @param {Boolean} [options.fin=true] Specifies whether the fragment is the - * last one - * @param {Boolean} [options.mask] Specifies whether or not to mask `data` - * @param {Function} [cb] Callback which is executed when data is written out - * @public - */ - send(data, options, cb) { - if (this.readyState === WebSocket.CONNECTING) { - throw new Error('WebSocket is not open: readyState 0 (CONNECTING)'); - } - - if (typeof options === 'function') { - cb = options; - options = {}; - } - - if (typeof data === 'number') data = data.toString(); - - if (this.readyState !== WebSocket.OPEN) { - sendAfterClose(this, data, cb); - return; - } - - const opts = { - binary: typeof data !== 'string', - mask: !this._isServer, - compress: true, - fin: true, - ...options - }; - - if (!this._extensions[PerMessageDeflate.extensionName]) { - opts.compress = false; - } - - this._sender.send(data || EMPTY_BUFFER, opts, cb); - } - - /** - * Forcibly close the connection. - * - * @public - */ - terminate() { - if (this.readyState === WebSocket.CLOSED) return; - if (this.readyState === WebSocket.CONNECTING) { - const msg = 'WebSocket was closed before the connection was established'; - abortHandshake(this, this._req, msg); - return; - } - - if (this._socket) { - this._readyState = WebSocket.CLOSING; - this._socket.destroy(); - } - } -} - -/** - * @constant {Number} CONNECTING - * @memberof WebSocket - */ -Object.defineProperty(WebSocket, 'CONNECTING', { - enumerable: true, - value: readyStates.indexOf('CONNECTING') -}); - -/** - * @constant {Number} CONNECTING - * @memberof WebSocket.prototype - */ -Object.defineProperty(WebSocket.prototype, 'CONNECTING', { - enumerable: true, - value: readyStates.indexOf('CONNECTING') -}); - -/** - * @constant {Number} OPEN - * @memberof WebSocket - */ -Object.defineProperty(WebSocket, 'OPEN', { - enumerable: true, - value: readyStates.indexOf('OPEN') -}); - -/** - * @constant {Number} OPEN - * @memberof WebSocket.prototype - */ -Object.defineProperty(WebSocket.prototype, 'OPEN', { - enumerable: true, - value: readyStates.indexOf('OPEN') -}); - -/** - * @constant {Number} CLOSING - * @memberof WebSocket - */ -Object.defineProperty(WebSocket, 'CLOSING', { - enumerable: true, - value: readyStates.indexOf('CLOSING') -}); - -/** - * @constant {Number} CLOSING - * @memberof WebSocket.prototype - */ -Object.defineProperty(WebSocket.prototype, 'CLOSING', { - enumerable: true, - value: readyStates.indexOf('CLOSING') -}); - -/** - * @constant {Number} CLOSED - * @memberof WebSocket - */ -Object.defineProperty(WebSocket, 'CLOSED', { - enumerable: true, - value: readyStates.indexOf('CLOSED') -}); - -/** - * @constant {Number} CLOSED - * @memberof WebSocket.prototype - */ -Object.defineProperty(WebSocket.prototype, 'CLOSED', { - enumerable: true, - value: readyStates.indexOf('CLOSED') -}); - -[ - 'binaryType', - 'bufferedAmount', - 'extensions', - 'isPaused', - 'protocol', - 'readyState', - 'url' -].forEach((property) => { - Object.defineProperty(WebSocket.prototype, property, { enumerable: true }); -}); - -// -// Add the `onopen`, `onerror`, `onclose`, and `onmessage` attributes. -// See https://html.spec.whatwg.org/multipage/comms.html#the-websocket-interface -// -['open', 'error', 'close', 'message'].forEach((method) => { - Object.defineProperty(WebSocket.prototype, `on${method}`, { - enumerable: true, - get() { - for (const listener of this.listeners(method)) { - if (listener[kForOnEventAttribute]) return listener[kListener]; - } - - return null; - }, - set(handler) { - for (const listener of this.listeners(method)) { - if (listener[kForOnEventAttribute]) { - this.removeListener(method, listener); - break; - } - } - - if (typeof handler !== 'function') return; - - this.addEventListener(method, handler, { - [kForOnEventAttribute]: true - }); - } - }); -}); - -WebSocket.prototype.addEventListener = addEventListener; -WebSocket.prototype.removeEventListener = removeEventListener; - -var websocket = WebSocket; - -/** - * Initialize a WebSocket client. - * - * @param {WebSocket} websocket The client to initialize - * @param {(String|URL)} address The URL to which to connect - * @param {Array} protocols The subprotocols - * @param {Object} [options] Connection options - * @param {Boolean} [options.allowSynchronousEvents=true] Specifies whether any - * of the `'message'`, `'ping'`, and `'pong'` events can be emitted multiple - * times in the same tick - * @param {Boolean} [options.autoPong=true] Specifies whether or not to - * automatically send a pong in response to a ping - * @param {Function} [options.finishRequest] A function which can be used to - * customize the headers of each http request before it is sent - * @param {Boolean} [options.followRedirects=false] Whether or not to follow - * redirects - * @param {Function} [options.generateMask] The function used to generate the - * masking key - * @param {Number} [options.handshakeTimeout] Timeout in milliseconds for the - * handshake request - * @param {Number} [options.maxPayload=104857600] The maximum allowed message - * size - * @param {Number} [options.maxRedirects=10] The maximum number of redirects - * allowed - * @param {String} [options.origin] Value of the `Origin` or - * `Sec-WebSocket-Origin` header - * @param {(Boolean|Object)} [options.perMessageDeflate=true] Enable/disable - * permessage-deflate - * @param {Number} [options.protocolVersion=13] Value of the - * `Sec-WebSocket-Version` header - * @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or - * not to skip UTF-8 validation for text and close messages - * @private - */ -function initAsClient(websocket, address, protocols, options) { - const opts = { - allowSynchronousEvents: true, - autoPong: true, - protocolVersion: protocolVersions[1], - maxPayload: 100 * 1024 * 1024, - skipUTF8Validation: false, - perMessageDeflate: true, - followRedirects: false, - maxRedirects: 10, - ...options, - socketPath: undefined, - hostname: undefined, - protocol: undefined, - timeout: undefined, - method: 'GET', - host: undefined, - path: undefined, - port: undefined - }; - - websocket._autoPong = opts.autoPong; - - if (!protocolVersions.includes(opts.protocolVersion)) { - throw new RangeError( - `Unsupported protocol version: ${opts.protocolVersion} ` + - `(supported versions: ${protocolVersions.join(', ')})` - ); - } - - let parsedUrl; - - if (address instanceof URL) { - parsedUrl = address; - } else { - try { - parsedUrl = new URL(address); - } catch (e) { - throw new SyntaxError(`Invalid URL: ${address}`); - } - } - - if (parsedUrl.protocol === 'http:') { - parsedUrl.protocol = 'ws:'; - } else if (parsedUrl.protocol === 'https:') { - parsedUrl.protocol = 'wss:'; - } - - websocket._url = parsedUrl.href; - - const isSecure = parsedUrl.protocol === 'wss:'; - const isIpcUrl = parsedUrl.protocol === 'ws+unix:'; - let invalidUrlMessage; - - if (parsedUrl.protocol !== 'ws:' && !isSecure && !isIpcUrl) { - invalidUrlMessage = - 'The URL\'s protocol must be one of "ws:", "wss:", ' + - '"http:", "https", or "ws+unix:"'; - } else if (isIpcUrl && !parsedUrl.pathname) { - invalidUrlMessage = "The URL's pathname is empty"; - } else if (parsedUrl.hash) { - invalidUrlMessage = 'The URL contains a fragment identifier'; - } - - if (invalidUrlMessage) { - const err = new SyntaxError(invalidUrlMessage); - - if (websocket._redirects === 0) { - throw err; - } else { - emitErrorAndClose(websocket, err); - return; - } - } - - const defaultPort = isSecure ? 443 : 80; - const key = randomBytes(16).toString('base64'); - const request = isSecure ? https.request : http.request; - const protocolSet = new Set(); - let perMessageDeflate; - - opts.createConnection = - opts.createConnection || (isSecure ? tlsConnect : netConnect); - opts.defaultPort = opts.defaultPort || defaultPort; - opts.port = parsedUrl.port || defaultPort; - opts.host = parsedUrl.hostname.startsWith('[') - ? parsedUrl.hostname.slice(1, -1) - : parsedUrl.hostname; - opts.headers = { - ...opts.headers, - 'Sec-WebSocket-Version': opts.protocolVersion, - 'Sec-WebSocket-Key': key, - Connection: 'Upgrade', - Upgrade: 'websocket' - }; - opts.path = parsedUrl.pathname + parsedUrl.search; - opts.timeout = opts.handshakeTimeout; - - if (opts.perMessageDeflate) { - perMessageDeflate = new PerMessageDeflate( - opts.perMessageDeflate !== true ? opts.perMessageDeflate : {}, - false, - opts.maxPayload - ); - opts.headers['Sec-WebSocket-Extensions'] = format({ - [PerMessageDeflate.extensionName]: perMessageDeflate.offer() - }); - } - if (protocols.length) { - for (const protocol of protocols) { - if ( - typeof protocol !== 'string' || - !subprotocolRegex.test(protocol) || - protocolSet.has(protocol) - ) { - throw new SyntaxError( - 'An invalid or duplicated subprotocol was specified' - ); - } - - protocolSet.add(protocol); - } - - opts.headers['Sec-WebSocket-Protocol'] = protocols.join(','); - } - if (opts.origin) { - if (opts.protocolVersion < 13) { - opts.headers['Sec-WebSocket-Origin'] = opts.origin; - } else { - opts.headers.Origin = opts.origin; - } - } - if (parsedUrl.username || parsedUrl.password) { - opts.auth = `${parsedUrl.username}:${parsedUrl.password}`; - } - - if (isIpcUrl) { - const parts = opts.path.split(':'); - - opts.socketPath = parts[0]; - opts.path = parts[1]; - } - - let req; - - if (opts.followRedirects) { - if (websocket._redirects === 0) { - websocket._originalIpc = isIpcUrl; - websocket._originalSecure = isSecure; - websocket._originalHostOrSocketPath = isIpcUrl - ? opts.socketPath - : parsedUrl.host; - - const headers = options && options.headers; - - // - // Shallow copy the user provided options so that headers can be changed - // without mutating the original object. - // - options = { ...options, headers: {} }; - - if (headers) { - for (const [key, value] of Object.entries(headers)) { - options.headers[key.toLowerCase()] = value; - } - } - } else if (websocket.listenerCount('redirect') === 0) { - const isSameHost = isIpcUrl - ? websocket._originalIpc - ? opts.socketPath === websocket._originalHostOrSocketPath - : false - : websocket._originalIpc - ? false - : parsedUrl.host === websocket._originalHostOrSocketPath; - - if (!isSameHost || (websocket._originalSecure && !isSecure)) { - // - // Match curl 7.77.0 behavior and drop the following headers. These - // headers are also dropped when following a redirect to a subdomain. - // - delete opts.headers.authorization; - delete opts.headers.cookie; - - if (!isSameHost) delete opts.headers.host; - - opts.auth = undefined; - } - } - - // - // Match curl 7.77.0 behavior and make the first `Authorization` header win. - // If the `Authorization` header is set, then there is nothing to do as it - // will take precedence. - // - if (opts.auth && !options.headers.authorization) { - options.headers.authorization = - 'Basic ' + Buffer.from(opts.auth).toString('base64'); - } - - req = websocket._req = request(opts); - - if (websocket._redirects) { - // - // Unlike what is done for the `'upgrade'` event, no early exit is - // triggered here if the user calls `websocket.close()` or - // `websocket.terminate()` from a listener of the `'redirect'` event. This - // is because the user can also call `request.destroy()` with an error - // before calling `websocket.close()` or `websocket.terminate()` and this - // would result in an error being emitted on the `request` object with no - // `'error'` event listeners attached. - // - websocket.emit('redirect', websocket.url, req); - } - } else { - req = websocket._req = request(opts); - } - - if (opts.timeout) { - req.on('timeout', () => { - abortHandshake(websocket, req, 'Opening handshake has timed out'); - }); - } - - req.on('error', (err) => { - if (req === null || req[kAborted]) return; - - req = websocket._req = null; - emitErrorAndClose(websocket, err); - }); - - req.on('response', (res) => { - const location = res.headers.location; - const statusCode = res.statusCode; - - if ( - location && - opts.followRedirects && - statusCode >= 300 && - statusCode < 400 - ) { - if (++websocket._redirects > opts.maxRedirects) { - abortHandshake(websocket, req, 'Maximum redirects exceeded'); - return; - } - - req.abort(); - - let addr; - - try { - addr = new URL(location, address); - } catch (e) { - const err = new SyntaxError(`Invalid URL: ${location}`); - emitErrorAndClose(websocket, err); - return; - } - - initAsClient(websocket, addr, protocols, options); - } else if (!websocket.emit('unexpected-response', req, res)) { - abortHandshake( - websocket, - req, - `Unexpected server response: ${res.statusCode}` - ); - } - }); - - req.on('upgrade', (res, socket, head) => { - websocket.emit('upgrade', res); - - // - // The user may have closed the connection from a listener of the - // `'upgrade'` event. - // - if (websocket.readyState !== WebSocket.CONNECTING) return; - - req = websocket._req = null; - - const upgrade = res.headers.upgrade; - - if (upgrade === undefined || upgrade.toLowerCase() !== 'websocket') { - abortHandshake(websocket, socket, 'Invalid Upgrade header'); - return; - } - - const digest = createHash('sha1') - .update(key + GUID) - .digest('base64'); - - if (res.headers['sec-websocket-accept'] !== digest) { - abortHandshake(websocket, socket, 'Invalid Sec-WebSocket-Accept header'); - return; - } - - const serverProt = res.headers['sec-websocket-protocol']; - let protError; - - if (serverProt !== undefined) { - if (!protocolSet.size) { - protError = 'Server sent a subprotocol but none was requested'; - } else if (!protocolSet.has(serverProt)) { - protError = 'Server sent an invalid subprotocol'; - } - } else if (protocolSet.size) { - protError = 'Server sent no subprotocol'; - } - - if (protError) { - abortHandshake(websocket, socket, protError); - return; - } - - if (serverProt) websocket._protocol = serverProt; - - const secWebSocketExtensions = res.headers['sec-websocket-extensions']; - - if (secWebSocketExtensions !== undefined) { - if (!perMessageDeflate) { - const message = - 'Server sent a Sec-WebSocket-Extensions header but no extension ' + - 'was requested'; - abortHandshake(websocket, socket, message); - return; - } - - let extensions; - - try { - extensions = parse(secWebSocketExtensions); - } catch (err) { - const message = 'Invalid Sec-WebSocket-Extensions header'; - abortHandshake(websocket, socket, message); - return; - } - - const extensionNames = Object.keys(extensions); - - if ( - extensionNames.length !== 1 || - extensionNames[0] !== PerMessageDeflate.extensionName - ) { - const message = 'Server indicated an extension that was not requested'; - abortHandshake(websocket, socket, message); - return; - } - - try { - perMessageDeflate.accept(extensions[PerMessageDeflate.extensionName]); - } catch (err) { - const message = 'Invalid Sec-WebSocket-Extensions header'; - abortHandshake(websocket, socket, message); - return; - } - - websocket._extensions[PerMessageDeflate.extensionName] = - perMessageDeflate; - } - - websocket.setSocket(socket, head, { - allowSynchronousEvents: opts.allowSynchronousEvents, - generateMask: opts.generateMask, - maxPayload: opts.maxPayload, - skipUTF8Validation: opts.skipUTF8Validation - }); - }); - - if (opts.finishRequest) { - opts.finishRequest(req, websocket); - } else { - req.end(); - } -} - -/** - * Emit the `'error'` and `'close'` events. - * - * @param {WebSocket} websocket The WebSocket instance - * @param {Error} The error to emit - * @private - */ -function emitErrorAndClose(websocket, err) { - websocket._readyState = WebSocket.CLOSING; - // - // The following assignment is practically useless and is done only for - // consistency. - // - websocket._errorEmitted = true; - websocket.emit('error', err); - websocket.emitClose(); -} - -/** - * Create a `net.Socket` and initiate a connection. - * - * @param {Object} options Connection options - * @return {net.Socket} The newly created socket used to start the connection - * @private - */ -function netConnect(options) { - options.path = options.socketPath; - return net.connect(options); -} - -/** - * Create a `tls.TLSSocket` and initiate a connection. - * - * @param {Object} options Connection options - * @return {tls.TLSSocket} The newly created socket used to start the connection - * @private - */ -function tlsConnect(options) { - options.path = undefined; - - if (!options.servername && options.servername !== '') { - options.servername = net.isIP(options.host) ? '' : options.host; - } - - return tls.connect(options); -} - -/** - * Abort the handshake and emit an error. - * - * @param {WebSocket} websocket The WebSocket instance - * @param {(http.ClientRequest|net.Socket|tls.Socket)} stream The request to - * abort or the socket to destroy - * @param {String} message The error message - * @private - */ -function abortHandshake(websocket, stream, message) { - websocket._readyState = WebSocket.CLOSING; - - const err = new Error(message); - Error.captureStackTrace(err, abortHandshake); - - if (stream.setHeader) { - stream[kAborted] = true; - stream.abort(); - - if (stream.socket && !stream.socket.destroyed) { - // - // On Node.js >= 14.3.0 `request.abort()` does not destroy the socket if - // called after the request completed. See - // https://github.com/websockets/ws/issues/1869. - // - stream.socket.destroy(); - } - - process.nextTick(emitErrorAndClose, websocket, err); - } else { - stream.destroy(err); - stream.once('error', websocket.emit.bind(websocket, 'error')); - stream.once('close', websocket.emitClose.bind(websocket)); - } -} - -/** - * Handle cases where the `ping()`, `pong()`, or `send()` methods are called - * when the `readyState` attribute is `CLOSING` or `CLOSED`. - * - * @param {WebSocket} websocket The WebSocket instance - * @param {*} [data] The data to send - * @param {Function} [cb] Callback - * @private - */ -function sendAfterClose(websocket, data, cb) { - if (data) { - const length = isBlob(data) ? data.size : toBuffer(data).length; - - // - // The `_bufferedAmount` property is used only when the peer is a client and - // the opening handshake fails. Under these circumstances, in fact, the - // `setSocket()` method is not called, so the `_socket` and `_sender` - // properties are set to `null`. - // - if (websocket._socket) websocket._sender._bufferedBytes += length; - else websocket._bufferedAmount += length; - } - - if (cb) { - const err = new Error( - `WebSocket is not open: readyState ${websocket.readyState} ` + - `(${readyStates[websocket.readyState]})` - ); - process.nextTick(cb, err); - } -} - -/** - * The listener of the `Receiver` `'conclude'` event. - * - * @param {Number} code The status code - * @param {Buffer} reason The reason for closing - * @private - */ -function receiverOnConclude(code, reason) { - const websocket = this[kWebSocket]; - - websocket._closeFrameReceived = true; - websocket._closeMessage = reason; - websocket._closeCode = code; - - if (websocket._socket[kWebSocket] === undefined) return; - - websocket._socket.removeListener('data', socketOnData); - process.nextTick(resume, websocket._socket); - - if (code === 1005) websocket.close(); - else websocket.close(code, reason); -} - -/** - * The listener of the `Receiver` `'drain'` event. - * - * @private - */ -function receiverOnDrain() { - const websocket = this[kWebSocket]; - - if (!websocket.isPaused) websocket._socket.resume(); -} - -/** - * The listener of the `Receiver` `'error'` event. - * - * @param {(RangeError|Error)} err The emitted error - * @private - */ -function receiverOnError(err) { - const websocket = this[kWebSocket]; - - if (websocket._socket[kWebSocket] !== undefined) { - websocket._socket.removeListener('data', socketOnData); - - // - // On Node.js < 14.0.0 the `'error'` event is emitted synchronously. See - // https://github.com/websockets/ws/issues/1940. - // - process.nextTick(resume, websocket._socket); - - websocket.close(err[kStatusCode]); - } - - if (!websocket._errorEmitted) { - websocket._errorEmitted = true; - websocket.emit('error', err); - } -} - -/** - * The listener of the `Receiver` `'finish'` event. - * - * @private - */ -function receiverOnFinish() { - this[kWebSocket].emitClose(); -} - -/** - * The listener of the `Receiver` `'message'` event. - * - * @param {Buffer|ArrayBuffer|Buffer[])} data The message - * @param {Boolean} isBinary Specifies whether the message is binary or not - * @private - */ -function receiverOnMessage(data, isBinary) { - this[kWebSocket].emit('message', data, isBinary); -} - -/** - * The listener of the `Receiver` `'ping'` event. - * - * @param {Buffer} data The data included in the ping frame - * @private - */ -function receiverOnPing(data) { - const websocket = this[kWebSocket]; - - if (websocket._autoPong) websocket.pong(data, !this._isServer, NOOP); - websocket.emit('ping', data); -} - -/** - * The listener of the `Receiver` `'pong'` event. - * - * @param {Buffer} data The data included in the pong frame - * @private - */ -function receiverOnPong(data) { - this[kWebSocket].emit('pong', data); -} - -/** - * Resume a readable stream - * - * @param {Readable} stream The readable stream - * @private - */ -function resume(stream) { - stream.resume(); -} - -/** - * The `Sender` error event handler. - * - * @param {Error} The error - * @private - */ -function senderOnError(err) { - const websocket = this[kWebSocket]; - - if (websocket.readyState === WebSocket.CLOSED) return; - if (websocket.readyState === WebSocket.OPEN) { - websocket._readyState = WebSocket.CLOSING; - setCloseTimer(websocket); - } - - // - // `socket.end()` is used instead of `socket.destroy()` to allow the other - // peer to finish sending queued data. There is no need to set a timer here - // because `CLOSING` means that it is already set or not needed. - // - this._socket.end(); - - if (!websocket._errorEmitted) { - websocket._errorEmitted = true; - websocket.emit('error', err); - } -} - -/** - * Set a timer to destroy the underlying raw socket of a WebSocket. - * - * @param {WebSocket} websocket The WebSocket instance - * @private - */ -function setCloseTimer(websocket) { - websocket._closeTimer = setTimeout( - websocket._socket.destroy.bind(websocket._socket), - closeTimeout - ); -} - -/** - * The listener of the socket `'close'` event. - * - * @private - */ -function socketOnClose() { - const websocket = this[kWebSocket]; - - this.removeListener('close', socketOnClose); - this.removeListener('data', socketOnData); - this.removeListener('end', socketOnEnd); - - websocket._readyState = WebSocket.CLOSING; - - let chunk; - - // - // The close frame might not have been received or the `'end'` event emitted, - // for example, if the socket was destroyed due to an error. Ensure that the - // `receiver` stream is closed after writing any remaining buffered data to - // it. If the readable side of the socket is in flowing mode then there is no - // buffered data as everything has been already written and `readable.read()` - // will return `null`. If instead, the socket is paused, any possible buffered - // data will be read as a single chunk. - // - if ( - !this._readableState.endEmitted && - !websocket._closeFrameReceived && - !websocket._receiver._writableState.errorEmitted && - (chunk = websocket._socket.read()) !== null - ) { - websocket._receiver.write(chunk); - } - - websocket._receiver.end(); - - this[kWebSocket] = undefined; - - clearTimeout(websocket._closeTimer); - - if ( - websocket._receiver._writableState.finished || - websocket._receiver._writableState.errorEmitted - ) { - websocket.emitClose(); - } else { - websocket._receiver.on('error', receiverOnFinish); - websocket._receiver.on('finish', receiverOnFinish); - } -} - -/** - * The listener of the socket `'data'` event. - * - * @param {Buffer} chunk A chunk of data - * @private - */ -function socketOnData(chunk) { - if (!this[kWebSocket]._receiver.write(chunk)) { - this.pause(); - } -} - -/** - * The listener of the socket `'end'` event. - * - * @private - */ -function socketOnEnd() { - const websocket = this[kWebSocket]; - - websocket._readyState = WebSocket.CLOSING; - websocket._receiver.end(); - this.end(); -} - -/** - * The listener of the socket `'error'` event. - * - * @private - */ -function socketOnError() { - const websocket = this[kWebSocket]; - - this.removeListener('error', socketOnError); - this.on('error', NOOP); - - if (websocket) { - websocket._readyState = WebSocket.CLOSING; - this.destroy(); - } -} - -const WebSocket$1 = /*@__PURE__*/getDefaultExportFromCjs(websocket); - -function _0x501d(){const _0x2c0f26=['608197TkUiFe','6612696aliQZa','340315LwBzLy','2883800XyCgdb','2wOynKJ','7qxUdUy','1323760eIuLRR','3068289tJKTSU','4318388QiAhNA','90iejwNu'];_0x501d=function(){return _0x2c0f26;};return _0x501d();}(function(_0x154808,_0x36e91c){const _0x541caf=_0x2f9f,_0x39008a=_0x154808();while(!![]){try{const _0x1275a8=parseInt(_0x541caf(0x1d0))/0x1+-parseInt(_0x541caf(0x1d4))/0x2*(parseInt(_0x541caf(0x1d7))/0x3)+parseInt(_0x541caf(0x1ce))/0x4+parseInt(_0x541caf(0x1d2))/0x5+-parseInt(_0x541caf(0x1d1))/0x6+-parseInt(_0x541caf(0x1d5))/0x7*(parseInt(_0x541caf(0x1d3))/0x8)+-parseInt(_0x541caf(0x1cf))/0x9*(-parseInt(_0x541caf(0x1d6))/0xa);if(_0x1275a8===_0x36e91c)break;else _0x39008a['push'](_0x39008a['shift']());}catch(_0x2e2549){_0x39008a['push'](_0x39008a['shift']());}}}(_0x501d,0x91157));function _0x2f9f(_0x556d1f,_0x1525d5){const _0x501d27=_0x501d();return _0x2f9f=function(_0x2f9fdb,_0x680ce3){_0x2f9fdb=_0x2f9fdb-0x1ce;let _0x2f203=_0x501d27[_0x2f9fdb];return _0x2f203;},_0x2f9f(_0x556d1f,_0x1525d5);}const MoeHooVersion='v1.0.0'; - -const _0xaf5b9c=_0x31ac;(function(_0x5dd6fa,_0x570bd8){const _0x2b1d2d=_0x31ac,_0x4c4505=_0x5dd6fa();while(!![]){try{const _0x3c2cc8=parseInt(_0x2b1d2d(0x9c))/0x1*(parseInt(_0x2b1d2d(0x88))/0x2)+parseInt(_0x2b1d2d(0x8a))/0x3+-parseInt(_0x2b1d2d(0x80))/0x4+parseInt(_0x2b1d2d(0xa2))/0x5*(parseInt(_0x2b1d2d(0xac))/0x6)+parseInt(_0x2b1d2d(0x89))/0x7+-parseInt(_0x2b1d2d(0xc5))/0x8+-parseInt(_0x2b1d2d(0x9f))/0x9*(parseInt(_0x2b1d2d(0x70))/0xa);if(_0x3c2cc8===_0x570bd8)break;else _0x4c4505['push'](_0x4c4505['shift']());}catch(_0xd79ac9){_0x4c4505['push'](_0x4c4505['shift']());}}}(_0x2ae6,0xba3db));function _0x2ae6(){const _0x89937f=['from','length','existsSync','bind','digest','\x20with\x20trace_id\x20','slice','RTLD_LAZY','dlopen','attemptReconnect','WebSocket\x20is\x20not\x20connected','[NTQQPacketApi]\x20dlopen\x20','[NTQQPacketApi]\x20MoeHoo\x20init\x20hook\x20send\x20addr\x20','createHash','isConnected','check','4854296EufyXt','connect','linux.arm64','reconnectAttempts','\x20已达到最大重连次数!','websocket','getMsgService','platform','clientUrl','sendPacket','[NTQQPacketApi]\x20MoeHooExport','available','30mIaRwh','[Core]\x20[Packet\x20Server]\x20已连接到\x20','[NTQQPacketApi]\x20MoeHoo\x20init\x20complete','then','arch','registerCallback','parse','NapCat.Packet\x20未初始化!','get','[Core]\x20[Packet:Native]\x20不支持的平台:\x20','init','MoeHooExport','[Core]\x20[Packet\x20Server]\x20尝试重连失败:','md5','[Core]\x20[Packet:Native]\x20缺失运行时文件:\x20','recv','4747604mKffhb','maxReconnectAttempts','sendCommand','catch','\x20complete','exports','ws://127.0.0.1:8086/ws','supportedPlatforms','584726uIgZig','2145801YLGobZ','1502328JwQTzI','debug','onerror','sendEvent','.node','data','InitHook','[NTQQPacketApi]\x20moehoo_path:','error','stringify','includes','update','\x20error:','onmessage','send','cmd','sendSsoCmdReqByContend','sendOidbPacket','5vtjhyH','onopen','copyFileSync','3539835nWkKzn','logger','wrapperSession','5dJYLwK','handleMessage','charAt','randText','darwin.arm64','[NTQQPacketApi]\x20moehoo_path_ori:','isAvailable','./moehoo/MoeHoo.','[Core]\x20[Packet\x20Server]\x20重连时出错:\x20','Method\x20not\x20implemented.','8804052MBbwYm','hex','random','url','message','log','linux.x64','put','sendCommandImpl'];_0x2ae6=function(){return _0x89937f;};return _0x2ae6();}let currentPath=import.meta['url'];currentPath=fileURLToPath(currentPath[_0xaf5b9c(0xaf)]??currentPath);const currentDir=dirname(currentPath),platform=process[_0xaf5b9c(0x6b)]+'.'+process[_0xaf5b9c(0x74)],moehooPathOri=_0x12fc62['join'](currentDir,_0xaf5b9c(0xa9)+platform+_0xaf5b9c(0x8e)),moehooPath=_0x12fc62['join'](currentDir,'./moehoo/MoeHoo.'+MoeHooVersion+_0xaf5b9c(0x8e));class PacketClient{['cb']=new LRUCache(0x1f4);[_0xaf5b9c(0xa8)]=![];[_0xaf5b9c(0xa1)];constructor(_0xfaa350){const _0x583090=_0xaf5b9c;this[_0x583090(0xa1)]=_0xfaa350;}['randText'](_0x3ff0f0){const _0x61f095=_0xaf5b9c;let _0x104a40='';const _0x2935fe='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';for(let _0xf5100f=0x0;_0xf5100f<_0x3ff0f0;_0xf5100f++){_0x104a40+=_0x2935fe[_0x61f095(0xa4)](Math['floor'](Math[_0x61f095(0xae)]()*_0x2935fe['length']));}return _0x104a40;}get['available'](){const _0x3cca7f=_0xaf5b9c;return this[_0x3cca7f(0xa8)];}async[_0xaf5b9c(0x75)](_0x52cf63,_0x8611e5,_0x323d90){const _0x4bbac4=_0xaf5b9c;this['cb']['put'](createHash$1(_0x4bbac4(0x7d))[_0x4bbac4(0x95)](_0x52cf63)['digest']('hex')+_0x8611e5,_0x323d90);}async[_0xaf5b9c(0x82)](_0x22610a,_0x4667c3,_0x520657,_0x4f9752=![],_0x22d0ed=0x4e20,_0x52f8f1=()=>{}){return new Promise((_0x219d7f,_0x299d79)=>{const _0x326230=_0x31ac,_0x184e43=setTimeout(()=>{const _0x106091=_0x31ac;_0x299d79(new Error('sendCommand\x20timed\x20out\x20after\x20'+_0x22d0ed+'\x20ms\x20for\x20'+_0x22610a+_0x106091(0xba)+_0x520657));},_0x22d0ed);this[_0x326230(0x75)](_0x520657,'send',async _0xa759eb=>{_0x52f8f1(_0xa759eb),!_0x4f9752&&(clearTimeout(_0x184e43),_0x219d7f(_0xa759eb));}),_0x4f9752&&this[_0x326230(0x75)](_0x520657,_0x326230(0x7f),async _0x1c82d1=>{clearTimeout(_0x184e43),_0x219d7f(_0x1c82d1);}),this['sendCommandImpl'](_0x22610a,_0x4667c3,_0x520657);});}async['sendPacket'](_0x386972,_0x24fe36,_0x351e3f=![]){return new Promise((_0x1bd34d,_0x1f8984)=>{const _0x4d0fcc=_0x31ac;if(!this[_0x4d0fcc(0x6f)])return console[_0x4d0fcc(0x92)](_0x4d0fcc(0x77)),void 0x0;const _0x21827a=require$$1$1[_0x4d0fcc(0xc2)](_0x4d0fcc(0x7d))[_0x4d0fcc(0x95)](_0x24fe36)[_0x4d0fcc(0xb9)](_0x4d0fcc(0xad)),_0x2afe7a=(this[_0x4d0fcc(0xa5)](0x4)+_0x21827a+_0x24fe36)[_0x4d0fcc(0xbb)](0x0,_0x24fe36[_0x4d0fcc(0xb6)]/0x2);this[_0x4d0fcc(0x82)](_0x386972,_0x24fe36,_0x2afe7a,_0x351e3f,0x4e20,async()=>{const _0x33b0aa=_0x4d0fcc;await this[_0x33b0aa(0xa1)][_0x33b0aa(0x6a)]()[_0x33b0aa(0x9a)](_0x386972,_0x2afe7a);})[_0x4d0fcc(0x73)](_0x4a7ea9=>_0x1bd34d(_0x4a7ea9))['catch'](_0x28d2e2=>_0x1f8984(_0x28d2e2));});}async[_0xaf5b9c(0x9b)](_0x394f52,_0x6f8a05=![]){const _0x46a9c9=_0xaf5b9c;return this[_0x46a9c9(0x6d)](_0x394f52[_0x46a9c9(0x99)],_0x394f52['data'],_0x6f8a05);}}function _0x31ac(_0x284f66,_0x33ab27){const _0x2ae60a=_0x2ae6();return _0x31ac=function(_0x31ac9f,_0x2ceba7){_0x31ac9f=_0x31ac9f-0x65;let _0x191350=_0x2ae60a[_0x31ac9f];return _0x191350;},_0x31ac(_0x284f66,_0x33ab27);}class WSPacketClient extends PacketClient{[_0xaf5b9c(0x69)];['isConnected']=![];['reconnectAttempts']=0x0;['maxReconnectAttempts']=0x3c;[_0xaf5b9c(0x6c)]='';[_0xaf5b9c(0xa0)]=console;constructor(_0x3adeb8){const _0x58027a=_0xaf5b9c;super(_0x3adeb8),this[_0x58027a(0x6c)]=_0x58027a(0x86);}[_0xaf5b9c(0xc4)](){return !![];}[_0xaf5b9c(0xb4)](_0x2dacf2,_0x135390,_0x4d55cd){const _0x4814fc=_0xaf5b9c;throw new Error(_0x4814fc(0xab));}['connect'](_0x439456){return new Promise((_0x3e581b,_0x4be03e)=>{const _0x4e381d=_0x31ac;this[_0x4e381d(0x69)]=new WebSocket$1(this[_0x4e381d(0x6c)]),this[_0x4e381d(0x69)]['on'](_0x4e381d(0x92),_0x248f25=>{}),this['websocket'][_0x4e381d(0x9d)]=()=>{const _0x59fc52=_0x4e381d;this[_0x59fc52(0xc3)]=!![],this[_0x59fc52(0x67)]=0x0,this[_0x59fc52(0xa0)]['log'][_0x59fc52(0xb8)](this[_0x59fc52(0xa0)])(_0x59fc52(0x71)+this['clientUrl']),_0x439456(),_0x3e581b();},this['websocket'][_0x4e381d(0x8c)]=_0x288d67=>{const _0x3abe3c=_0x4e381d;_0x4be03e(new Error(''+_0x288d67[_0x3abe3c(0xb0)]));},this[_0x4e381d(0x69)][_0x4e381d(0x97)]=_0x426698=>{const _0x4ffc34=_0x4e381d;this['handleMessage'](_0x426698[_0x4ffc34(0x8f)])['then']()[_0x4ffc34(0x83)]();},this['websocket']['onclose']=()=>{const _0x5f1d9c=_0x4e381d;this['isConnected']=![],this[_0x5f1d9c(0xbe)](_0x439456);};});}[_0xaf5b9c(0xbe)](_0xc305cb){const _0x5934c5=_0xaf5b9c;try{this[_0x5934c5(0x67)]{const _0x5edccf=_0x5934c5;this[_0x5edccf(0x65)](_0xc305cb)[_0x5edccf(0x83)](_0xd70d24=>{const _0x593dad=_0x5edccf;this['logger'][_0x593dad(0x92)][_0x593dad(0xb8)](this[_0x593dad(0xa0)])(_0x593dad(0x7c)+_0xd70d24[_0x593dad(0xb0)]);});},0x1388*this[_0x5934c5(0x67)])):this['logger'][_0x5934c5(0x92)][_0x5934c5(0xb8)](this[_0x5934c5(0xa0)])('[Core]\x20[Packet\x20Server]\x20'+this[_0x5934c5(0x6c)]+_0x5934c5(0x68));}catch(_0x372db4){this['logger'][_0x5934c5(0x92)][_0x5934c5(0xb8)](this[_0x5934c5(0xa0)])(_0x5934c5(0xaa)+_0x372db4[_0x5934c5(0xb0)]);}}async['init'](_0x3b6ba6,_0x1d9ae6,_0x3427ac){const _0x31ca00=_0xaf5b9c;if(!this[_0x31ca00(0xc3)]||!this[_0x31ca00(0x69)])throw new Error(_0x31ca00(0xbf));const _0x12cefc={'action':_0x31ca00(0x7a),'pid':_0x3b6ba6,'recv':_0x1d9ae6,'send':_0x3427ac};this[_0x31ca00(0x69)][_0x31ca00(0x98)](JSON[_0x31ca00(0x93)](_0x12cefc));}async[_0xaf5b9c(0xa3)](_0x4242ad){const _0x5c3381=_0xaf5b9c;try{const _0x475e73=JSON[_0x5c3381(0x76)](_0x4242ad['toString']()),_0x3d7209=_0x475e73['trace_id_md5'],_0x3b2dda=_0x475e73?.['type']??_0x5c3381(0x7a),_0x328c1b=this['cb'][_0x5c3381(0x78)](_0x3d7209+_0x3b2dda);_0x328c1b&&await _0x328c1b(_0x475e73['data']);}catch(_0x1e93c5){this[_0x5c3381(0xa0)][_0x5c3381(0x92)][_0x5c3381(0xb8)](this[_0x5c3381(0xa0)])('Error\x20parsing\x20message:\x20'+_0x1e93c5);}}}class NativePacketClient extends PacketClient{['supportedPlatforms']=['win32.x64',_0xaf5b9c(0xb2),_0xaf5b9c(0x66),_0xaf5b9c(0xa6)];[_0xaf5b9c(0x7b)]={'exports':{}};[_0xaf5b9c(0x8d)]=new LRUCache(0x1f4);constructor(_0x3196e1){super(_0x3196e1);}get[_0xaf5b9c(0x6f)](){const _0x3081f9=_0xaf5b9c;return this[_0x3081f9(0xa8)];}[_0xaf5b9c(0xc4)](){const _0x5b7bfc=_0xaf5b9c;console[_0x5b7bfc(0xb1)]('[NTQQPacketApi]\x20开始检查支持的平台');const _0x349477=process[_0x5b7bfc(0x6b)]+'.'+process[_0x5b7bfc(0x74)];if(!this[_0x5b7bfc(0x87)][_0x5b7bfc(0x94)](_0x349477))return console['log'](_0x5b7bfc(0x79)+_0x349477),![];if(!_0x2e82e7[_0x5b7bfc(0xb7)](moehooPathOri))return console[_0x5b7bfc(0xb1)](_0x5b7bfc(0x7e)+moehooPath),![];return !![];}async['init'](_0x2e0080,_0x3311cd,_0x39ce5a){const _0x580aef=_0xaf5b9c;console[_0x580aef(0xb1)](_0x580aef(0xa7),moehooPathOri),console[_0x580aef(0xb1)](_0x580aef(0x91),moehooPath);if(_0x2e82e7[_0x580aef(0xb7)](moehooPathOri)&&!_0x2e82e7['existsSync'](moehooPath))try{_0x2e82e7[_0x580aef(0x9e)](moehooPathOri,moehooPath);}catch(_0x4115c7){console[_0x580aef(0xb1)]('[NTQQPacketApi]\x20copy\x20moehoo\x20error:',_0x4115c7);}try{process[_0x580aef(0xbd)](this['MoeHooExport'],moehooPath,constants$1['dlopen'][_0x580aef(0xbc)]),console[_0x580aef(0xb1)]('[NTQQPacketApi]\x20dlopen\x20'+moehooPath+_0x580aef(0x84));}catch(_0x16b566){console[_0x580aef(0x92)](_0x580aef(0xc0)+moehooPath+_0x580aef(0x96),_0x16b566);}try{console[_0x580aef(0xb1)](_0x580aef(0x6e),this[_0x580aef(0x7b)]),console[_0x580aef(0xb1)](_0x580aef(0xc1)+_0x39ce5a+',\x20recv\x20addr\x20'+_0x3311cd),this[_0x580aef(0x7b)][_0x580aef(0x85)][_0x580aef(0x90)]?.(_0x39ce5a,_0x3311cd,(_0x2a77c8,_0x2a9696,_0x290c73,_0x4e4810,_0x5cd131)=>{const _0x5bb480=_0x580aef,_0x5c3263=createHash$1('md5')[_0x5bb480(0x95)](Buffer[_0x5bb480(0xb5)](_0x5cd131,_0x5bb480(0xad)))[_0x5bb480(0xb9)]('hex');_0x2a77c8===0x0&&this['cb'][_0x5bb480(0x78)](_0x5c3263+'recv')&&this[_0x5bb480(0x8d)][_0x5bb480(0xb3)](_0x4e4810,_0x5c3263);if(_0x2a77c8===0x1&&this['sendEvent'][_0x5bb480(0x78)](_0x4e4810)){const _0x2b86c9=this[_0x5bb480(0x8d)][_0x5bb480(0x78)](_0x4e4810),_0x2d6bf9=this['cb'][_0x5bb480(0x78)](_0x2b86c9+_0x5bb480(0x7f));_0x2d6bf9?.({'seq':_0x4e4810,'cmd':_0x290c73,'hex_data':_0x5cd131});}}),console[_0x580aef(0x8b)](_0x580aef(0x72));}catch(_0x1505c7){console[_0x580aef(0x92)]('[NTQQPacketApi]\x20MoeHoo\x20init\x20error:',_0x1505c7);}this[_0x580aef(0xa8)]=!![];}[_0xaf5b9c(0xb4)](_0x228ced,_0x501169,_0xfb5bfa){const _0x265d61=_0xaf5b9c,_0x218ec8=createHash$1(_0x265d61(0x7d))[_0x265d61(0x95)](_0xfb5bfa)[_0x265d61(0xb9)](_0x265d61(0xad));this[_0x265d61(0x7b)][_0x265d61(0x85)]['SendPacket']?.(_0x228ced,_0x501169,_0x218ec8),this['cb'][_0x265d61(0x78)](_0x218ec8+_0x265d61(0x98))?.({'seq':0x0,'cmd':_0x228ced,'hex_data':''});}['connect'](_0x3c6bb9){return _0x3c6bb9(),Promise['resolve']();}} +const _0x387b3b=_0x166a;(function(_0x4b2af9,_0x962f0b){const _0x164bf0=_0x166a,_0x4e18d2=_0x4b2af9();while(!![]){try{const _0x6c6b64=-parseInt(_0x164bf0(0x141))/0x1+-parseInt(_0x164bf0(0x15f))/0x2*(-parseInt(_0x164bf0(0x155))/0x3)+parseInt(_0x164bf0(0x13a))/0x4*(-parseInt(_0x164bf0(0x176))/0x5)+parseInt(_0x164bf0(0x157))/0x6+-parseInt(_0x164bf0(0x161))/0x7+parseInt(_0x164bf0(0x159))/0x8+parseInt(_0x164bf0(0x160))/0x9*(parseInt(_0x164bf0(0x164))/0xa);if(_0x6c6b64===_0x962f0b)break;else _0x4e18d2['push'](_0x4e18d2['shift']());}catch(_0x43386d){_0x4e18d2['push'](_0x4e18d2['shift']());}}}(_0x2d12,0x8372a));function _0x2d12(){const _0x3044ce=['supportedPlatforms','floor','recv','129346oCDMtI','270WpGRsy','6797567AaQgAe','check','ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789','71410elkDGf','update','isAvailable','hex','[NTQQPacketApi]\x20moehoo_path_ori:','platform','digest','[NTQQPacketApi]\x20dlopen\x20','url','[NTQQPacketApi]\x20moehoo_path:','available','debug','darwin.arm64','sendSsoCmdReqByContend','getMsgService','sendOidbPacket','\x20ms\x20for\x20',',\x20recv\x20addr\x20','85MvNrle','data','init','registerCallback','wrapperSession','\x20with\x20trace_id\x20','sendPacket','[Core]\x20[Packet:Native]\x20缺失运行时文件:\x20','catch','./moehoo/MoeHoo.','.node','put','error','resolve','17092UbqaTR','connect','\x20complete','NapCat.Packet\x20未初始化!','linux.arm64','sendCommand','log','408825NoWwPW','[NTQQPacketApi]\x20MoeHoo\x20init\x20hook\x20send\x20addr\x20','arch','sendEvent','includes','MoeHooExport','SendPacket','[Core]\x20[Packet:Native]\x20不支持的平台:\x20','then','get','[NTQQPacketApi]\x20MoeHooExport','random','RTLD_LAZY','length','existsSync','dlopen','sendCommandImpl','join','[NTQQPacketApi]\x20开始检查支持的平台','\x20error:','42VTgabD','md5','1013118eGidyU','from','5619616ISWNBZ','exports','[NTQQPacketApi]\x20MoeHoo\x20init\x20complete'];_0x2d12=function(){return _0x3044ce;};return _0x2d12();}let currentPath=import.meta[_0x387b3b(0x16c)];currentPath=fileURLToPath(currentPath['url']??currentPath);const currentDir=dirname(currentPath),platform=process[_0x387b3b(0x169)]+'.'+process[_0x387b3b(0x143)],moehooPathOri=_0x49c13c['join'](currentDir,_0x387b3b(0x17f)+platform+'.node'),moehooPath=_0x49c13c[_0x387b3b(0x152)](currentDir,'./moehoo/MoeHoo.'+MoeHooVersion+_0x387b3b(0x136));function _0x166a(_0x907cea,_0x250be8){const _0x2d1207=_0x2d12();return _0x166a=function(_0x166aeb,_0x5af1aa){_0x166aeb=_0x166aeb-0x136;let _0x2aa8f9=_0x2d1207[_0x166aeb];return _0x2aa8f9;},_0x166a(_0x907cea,_0x250be8);}class PacketClient{['cb']=new LRUCache(0x1f4);[_0x387b3b(0x166)]=![];[_0x387b3b(0x17a)];constructor(_0x70100e){this['wrapperSession']=_0x70100e;}['randText'](_0x384221){const _0x4acf0c=_0x387b3b;let _0x1d511b='';const _0x3b6a30=_0x4acf0c(0x163);for(let _0x3301c9=0x0;_0x3301c9<_0x384221;_0x3301c9++){_0x1d511b+=_0x3b6a30['charAt'](Math[_0x4acf0c(0x15d)](Math[_0x4acf0c(0x14c)]()*_0x3b6a30[_0x4acf0c(0x14e)]));}return _0x1d511b;}get['available'](){return this['isAvailable'];}async['registerCallback'](_0x130430,_0x1ad0f7,_0x4d91c4){const _0x5c03fd=_0x387b3b;this['cb'][_0x5c03fd(0x137)](createHash(_0x5c03fd(0x156))[_0x5c03fd(0x165)](_0x130430)[_0x5c03fd(0x16a)]('hex')+_0x1ad0f7,_0x4d91c4);}async[_0x387b3b(0x13f)](_0x328b23,_0x48621d,_0x3c78cf,_0x14d23b=![],_0x29c46d=0x4e20,_0x4eb161=()=>{}){return new Promise((_0xa63e9,_0x17ff85)=>{const _0x4400a3=_0x166a,_0x77171=setTimeout(()=>{const _0x486d54=_0x166a;_0x17ff85(new Error('sendCommand\x20timed\x20out\x20after\x20'+_0x29c46d+_0x486d54(0x174)+_0x328b23+_0x486d54(0x17b)+_0x3c78cf));},_0x29c46d);this[_0x4400a3(0x179)](_0x3c78cf,'send',async _0x3b37a0=>{_0x4eb161(_0x3b37a0),!_0x14d23b&&(clearTimeout(_0x77171),_0xa63e9(_0x3b37a0));}),_0x14d23b&&this[_0x4400a3(0x179)](_0x3c78cf,_0x4400a3(0x15e),async _0x53113a=>{clearTimeout(_0x77171),_0xa63e9(_0x53113a);}),this[_0x4400a3(0x151)](_0x328b23,_0x48621d,_0x3c78cf);});}async[_0x387b3b(0x17c)](_0x222df2,_0x2d73ce,_0x51806b=![]){return new Promise((_0x5e864d,_0x203ea4)=>{const _0x1d932b=_0x166a;if(!this[_0x1d932b(0x16e)])return console['error'](_0x1d932b(0x13d)),void 0x0;const _0x40e3b6=_0x2cf5c6['createHash'](_0x1d932b(0x156))[_0x1d932b(0x165)](_0x2d73ce)[_0x1d932b(0x16a)]('hex'),_0x39b5fd=(this['randText'](0x4)+_0x40e3b6+_0x2d73ce)['slice'](0x0,_0x2d73ce['length']/0x2);this[_0x1d932b(0x13f)](_0x222df2,_0x2d73ce,_0x39b5fd,_0x51806b,0x4e20,async()=>{const _0x17942d=_0x1d932b;await this['wrapperSession'][_0x17942d(0x172)]()[_0x17942d(0x171)](_0x222df2,_0x39b5fd);})[_0x1d932b(0x149)](_0x520d87=>_0x5e864d(_0x520d87))[_0x1d932b(0x17e)](_0x302a31=>_0x203ea4(_0x302a31));});}async[_0x387b3b(0x173)](_0xc8fa1c,_0x138de7=![]){const _0x1ebb98=_0x387b3b;return this[_0x1ebb98(0x17c)](_0xc8fa1c['cmd'],_0xc8fa1c[_0x1ebb98(0x177)],_0x138de7);}}class NativePacketClient extends PacketClient{[_0x387b3b(0x15c)]=['win32.x64','linux.x64',_0x387b3b(0x13e),_0x387b3b(0x170)];[_0x387b3b(0x146)]={'exports':{}};[_0x387b3b(0x144)]=new LRUCache(0x1f4);constructor(_0x7feafc){super(_0x7feafc);}get['available'](){const _0x45da77=_0x387b3b;return this[_0x45da77(0x166)];}[_0x387b3b(0x162)](){const _0x47080f=_0x387b3b;console[_0x47080f(0x140)](_0x47080f(0x153));const _0x2885ce=process[_0x47080f(0x169)]+'.'+process[_0x47080f(0x143)];if(!this[_0x47080f(0x15c)][_0x47080f(0x145)](_0x2885ce))return console[_0x47080f(0x140)](_0x47080f(0x148)+_0x2885ce),![];if(!_0x3f08f4['existsSync'](moehooPathOri))return console['log'](_0x47080f(0x17d)+moehooPath),![];return !![];}async[_0x387b3b(0x178)](_0x106902,_0x2da465,_0x2fa422){const _0x3bfe80=_0x387b3b;console[_0x3bfe80(0x140)](_0x3bfe80(0x168),moehooPathOri),console[_0x3bfe80(0x140)](_0x3bfe80(0x16d),moehooPath);if(_0x3f08f4[_0x3bfe80(0x14f)](moehooPathOri)&&!_0x3f08f4[_0x3bfe80(0x14f)](moehooPath))try{_0x3f08f4['copyFileSync'](moehooPathOri,moehooPath);}catch(_0xc017cc){console['log']('[NTQQPacketApi]\x20copy\x20moehoo\x20error:',_0xc017cc);}try{process[_0x3bfe80(0x150)](this['MoeHooExport'],moehooPath,constants[_0x3bfe80(0x150)][_0x3bfe80(0x14d)]),console[_0x3bfe80(0x140)](_0x3bfe80(0x16b)+moehooPath+_0x3bfe80(0x13c));}catch(_0xcf55c4){console[_0x3bfe80(0x138)](_0x3bfe80(0x16b)+moehooPath+_0x3bfe80(0x154),_0xcf55c4);}try{console['log'](_0x3bfe80(0x14b),this[_0x3bfe80(0x146)]),console[_0x3bfe80(0x140)](_0x3bfe80(0x142)+_0x2fa422+_0x3bfe80(0x175)+_0x2da465),this['MoeHooExport']['exports']['InitHook']?.(_0x2fa422,_0x2da465,(_0x5333f2,_0x5f5284,_0x40f041,_0x227ad9,_0x4fe8ce)=>{const _0x1f338f=_0x3bfe80,_0xf2bf90=createHash(_0x1f338f(0x156))['update'](Buffer[_0x1f338f(0x158)](_0x4fe8ce,_0x1f338f(0x167)))[_0x1f338f(0x16a)]('hex');_0x5333f2===0x0&&this['cb'][_0x1f338f(0x14a)](_0xf2bf90+_0x1f338f(0x15e))&&this[_0x1f338f(0x144)]['put'](_0x227ad9,_0xf2bf90);if(_0x5333f2===0x1&&this[_0x1f338f(0x144)][_0x1f338f(0x14a)](_0x227ad9)){const _0x41dbe4=this[_0x1f338f(0x144)][_0x1f338f(0x14a)](_0x227ad9),_0x7d5732=this['cb'][_0x1f338f(0x14a)](_0x41dbe4+_0x1f338f(0x15e));_0x7d5732?.({'seq':_0x227ad9,'cmd':_0x40f041,'hex_data':_0x4fe8ce});}}),console[_0x3bfe80(0x16f)](_0x3bfe80(0x15b));}catch(_0x30363c){console[_0x3bfe80(0x138)]('[NTQQPacketApi]\x20MoeHoo\x20init\x20error:',_0x30363c);}this[_0x3bfe80(0x166)]=!![];}['sendCommandImpl'](_0x321775,_0x2842ed,_0x39545e){const _0x3a5c40=_0x387b3b,_0x3a2dd1=createHash(_0x3a5c40(0x156))['update'](_0x39545e)[_0x3a5c40(0x16a)]('hex');this[_0x3a5c40(0x146)][_0x3a5c40(0x15a)][_0x3a5c40(0x147)]?.(_0x321775,_0x2842ed,_0x3a2dd1),this['cb']['get'](_0x3a2dd1+'send')?.({'seq':0x0,'cmd':_0x321775,'hex_data':''});}[_0x387b3b(0x13b)](_0x30d149){const _0x4a3ed5=_0x387b3b;return _0x30d149(),Promise[_0x4a3ed5(0x139)]();}} /** * Get the type of a JSON value. @@ -7077,111 +3048,20 @@ class MessageType { } } -const _0x4a50fe=_0x5704;function _0x3d19(){const _0x5c8d74=['message','scalar','function','create','13551768jqvAkm','3729uXQVsb','optional','104514SuAxSb','get','keys','repeat','decode','map','set','_proto_msg','STRING','toBinary','_field','UNPACKED','realMsg','866565hNzUkE','type','2396SZpTBx','PACKED','2015845oXyUNc','cache','kind','encode','3783948ohFnyt','150782xXeXnn','getInstance','BYTES','fromBinary'];_0x3d19=function(){return _0x5c8d74;};return _0x3d19();}(function(_0x10001c,_0x20adb5){const _0x73b624=_0x5704,_0x50798c=_0x10001c();while(!![]){try{const _0x4e2797=-parseInt(_0x73b624(0x1c6))/0x1+-parseInt(_0x73b624(0x1dc))/0x2+-parseInt(_0x73b624(0x1c4))/0x3*(parseInt(_0x73b624(0x1d5))/0x4)+parseInt(_0x73b624(0x1d7))/0x5+-parseInt(_0x73b624(0x1db))/0x6+-parseInt(_0x73b624(0x1d3))/0x7+parseInt(_0x73b624(0x1c3))/0x8;if(_0x4e2797===_0x20adb5)break;else _0x50798c['push'](_0x50798c['shift']());}catch(_0x51eed0){_0x50798c['push'](_0x50798c['shift']());}}}(_0x3d19,0x661b1));function _0x5704(_0x426498,_0x6dfe04){const _0x3d19cd=_0x3d19();return _0x5704=function(_0x5704b1,_0x42613f){_0x5704b1=_0x5704b1-0x1bf;let _0x3f3fbc=_0x3d19cd[_0x5704b1];return _0x3f3fbc;},_0x5704(_0x426498,_0x6dfe04);}function ProtoField(_0x131fa2,_0x20577f,_0x513451,_0x295b5f){const _0x139727=_0x5704;return typeof _0x20577f===_0x139727(0x1c1)?{'kind':_0x139727(0x1bf),'no':_0x131fa2,'type':_0x20577f,'optional':_0x513451??![],'repeat':![]}:{'kind':_0x139727(0x1c0),'no':_0x131fa2,'type':_0x20577f,'optional':_0x513451??![],'repeat':![]};}class NapProtoRealMsg{[_0x4a50fe(0x1d0)];[_0x4a50fe(0x1cd)];static [_0x4a50fe(0x1d8)]=new WeakMap();constructor(_0x2fa9e6){const _0x2f3aaa=_0x4a50fe;this[_0x2f3aaa(0x1d0)]=Object[_0x2f3aaa(0x1c8)](_0x2fa9e6)[_0x2f3aaa(0x1cb)](_0x558c90=>{const _0x3693ca=_0x2f3aaa,_0x4ecede=_0x2fa9e6[_0x558c90];if(_0x4ecede[_0x3693ca(0x1d9)]===_0x3693ca(0x1c0)){const _0x3c9585=_0x4ecede['repeat']?[ScalarType[_0x3693ca(0x1ce)],ScalarType[_0x3693ca(0x1de)]]['includes'](_0x4ecede['type'])?RepeatType[_0x3693ca(0x1d1)]:RepeatType[_0x3693ca(0x1d6)]:RepeatType['NO'];return {'no':_0x4ecede['no'],'name':_0x558c90,'kind':'scalar','T':_0x4ecede[_0x3693ca(0x1d4)],'opt':_0x4ecede[_0x3693ca(0x1c5)],'repeat':_0x3c9585};}else {if(_0x4ecede[_0x3693ca(0x1d9)]===_0x3693ca(0x1bf))return {'no':_0x4ecede['no'],'name':_0x558c90,'kind':_0x3693ca(0x1bf),'repeat':_0x4ecede[_0x3693ca(0x1c9)]?RepeatType[_0x3693ca(0x1d6)]:RepeatType['NO'],'T':()=>NapProtoRealMsg['getInstance'](_0x4ecede[_0x3693ca(0x1d4)]())[_0x3693ca(0x1cd)]};}}),this[_0x2f3aaa(0x1cd)]=new MessageType('nya',this[_0x2f3aaa(0x1d0)]);}static[_0x4a50fe(0x1dd)](_0x597da6){const _0x4867b7=_0x4a50fe;let _0x5b3247=this[_0x4867b7(0x1d8)][_0x4867b7(0x1c7)](_0x597da6);return !_0x5b3247&&(_0x5b3247=new NapProtoRealMsg(_0x597da6),this[_0x4867b7(0x1d8)][_0x4867b7(0x1cc)](_0x597da6,_0x5b3247)),_0x5b3247;}['encode'](_0xb0674d){const _0x2c5413=_0x4a50fe;return this[_0x2c5413(0x1cd)][_0x2c5413(0x1cf)](this[_0x2c5413(0x1cd)][_0x2c5413(0x1c2)](_0xb0674d));}[_0x4a50fe(0x1ca)](_0x257927){const _0x48cf39=_0x4a50fe;return this['_proto_msg'][_0x48cf39(0x1df)](_0x257927);}}class NapProtoMsg{[_0x4a50fe(0x1d2)];constructor(_0x203315){const _0x442a25=_0x4a50fe;this[_0x442a25(0x1d2)]=NapProtoRealMsg[_0x442a25(0x1dd)](_0x203315);}['encode'](_0x4e4cc3){const _0x1472bb=_0x4a50fe;return this[_0x1472bb(0x1d2)][_0x1472bb(0x1da)](_0x4e4cc3);}[_0x4a50fe(0x1ca)](_0x53069d){const _0x3861ff=_0x4a50fe;return this['realMsg'][_0x3861ff(0x1ca)](_0x53069d);}} +const _0x37a6a4=_0x38cf;(function(_0x29813a,_0x4e7013){const _0x36858a=_0x38cf,_0x123c83=_0x29813a();while(!![]){try{const _0x248abb=parseInt(_0x36858a(0xa0))/0x1*(parseInt(_0x36858a(0x8c))/0x2)+parseInt(_0x36858a(0xa2))/0x3+-parseInt(_0x36858a(0x9e))/0x4+-parseInt(_0x36858a(0xa1))/0x5*(-parseInt(_0x36858a(0x8e))/0x6)+parseInt(_0x36858a(0x8d))/0x7*(parseInt(_0x36858a(0x87))/0x8)+parseInt(_0x36858a(0x98))/0x9*(parseInt(_0x36858a(0xa6))/0xa)+-parseInt(_0x36858a(0xa4))/0xb;if(_0x248abb===_0x4e7013)break;else _0x123c83['push'](_0x123c83['shift']());}catch(_0x59b96f){_0x123c83['push'](_0x123c83['shift']());}}}(_0x2ba1,0x2d578));function _0x2ba1(){const _0x642ab5=['optional','cache','UNPACKED','279340lVoJlt','map','1kQeQQn','145245SLLOnj','268503tJJBZV','kind','3307678zyfFLR','includes','25280gZKvvo','create','37096gafcTA','function','getInstance','nya','message','707752qeXIPJ','14HGYBgP','12WXaLlM','_field','type','toBinary','PACKED','scalar','encode','get','_proto_msg','STRING','162llxLBj','decode','repeat'];_0x2ba1=function(){return _0x642ab5;};return _0x2ba1();}function ProtoField(_0x3e5e5f,_0x20c891,_0x30f26e,_0x18abcb){const _0x54a180=_0x38cf;return typeof _0x20c891===_0x54a180(0x88)?{'kind':'message','no':_0x3e5e5f,'type':_0x20c891,'optional':_0x30f26e??![],'repeat':![]}:{'kind':_0x54a180(0x93),'no':_0x3e5e5f,'type':_0x20c891,'optional':_0x30f26e??![],'repeat':![]};}class NapProtoRealMsg{['_field'];[_0x37a6a4(0x96)];static [_0x37a6a4(0x9c)]=new WeakMap();constructor(_0x29bfcf){const _0x4abf7f=_0x37a6a4;this['_field']=Object['keys'](_0x29bfcf)[_0x4abf7f(0x9f)](_0x4366c5=>{const _0x57f988=_0x4abf7f,_0x3ce6fe=_0x29bfcf[_0x4366c5];if(_0x3ce6fe[_0x57f988(0xa3)]===_0x57f988(0x93)){const _0x24b23e=_0x3ce6fe[_0x57f988(0x9a)]?[ScalarType[_0x57f988(0x97)],ScalarType['BYTES']][_0x57f988(0xa5)](_0x3ce6fe[_0x57f988(0x90)])?RepeatType[_0x57f988(0x9d)]:RepeatType[_0x57f988(0x92)]:RepeatType['NO'];return {'no':_0x3ce6fe['no'],'name':_0x4366c5,'kind':_0x57f988(0x93),'T':_0x3ce6fe[_0x57f988(0x90)],'opt':_0x3ce6fe[_0x57f988(0x9b)],'repeat':_0x24b23e};}else {if(_0x3ce6fe['kind']===_0x57f988(0x8b))return {'no':_0x3ce6fe['no'],'name':_0x4366c5,'kind':_0x57f988(0x8b),'repeat':_0x3ce6fe[_0x57f988(0x9a)]?RepeatType['PACKED']:RepeatType['NO'],'T':()=>NapProtoRealMsg[_0x57f988(0x89)](_0x3ce6fe['type']())[_0x57f988(0x96)]};}}),this[_0x4abf7f(0x96)]=new MessageType(_0x4abf7f(0x8a),this[_0x4abf7f(0x8f)]);}static[_0x37a6a4(0x89)](_0x57c729){const _0x5ebb2f=_0x37a6a4;let _0x459572=this[_0x5ebb2f(0x9c)][_0x5ebb2f(0x95)](_0x57c729);return !_0x459572&&(_0x459572=new NapProtoRealMsg(_0x57c729),this[_0x5ebb2f(0x9c)]['set'](_0x57c729,_0x459572)),_0x459572;}['encode'](_0x123b98){const _0x1fda8f=_0x37a6a4;return this[_0x1fda8f(0x96)][_0x1fda8f(0x91)](this[_0x1fda8f(0x96)][_0x1fda8f(0x86)](_0x123b98));}[_0x37a6a4(0x99)](_0x5488fa){const _0x146a07=_0x37a6a4;return this[_0x146a07(0x96)]['fromBinary'](_0x5488fa);}}function _0x38cf(_0x5ecaf2,_0x5b5728){const _0x2ba149=_0x2ba1();return _0x38cf=function(_0x38cf57,_0x369f98){_0x38cf57=_0x38cf57-0x86;let _0xde3964=_0x2ba149[_0x38cf57];return _0xde3964;},_0x38cf(_0x5ecaf2,_0x5b5728);}class NapProtoMsg{['realMsg'];constructor(_0x9bdc7f){const _0x42fba0=_0x37a6a4;this['realMsg']=NapProtoRealMsg[_0x42fba0(0x89)](_0x9bdc7f);}[_0x37a6a4(0x94)](_0xf116f0){const _0x131c45=_0x37a6a4;return this['realMsg'][_0x131c45(0x94)](_0xf116f0);}[_0x37a6a4(0x99)](_0x4f310c){const _0x706864=_0x37a6a4;return this['realMsg'][_0x706864(0x99)](_0x4f310c);}} -const _0x87d853=_0x150a;function _0x4e5e(){const _0x59c97b=['303001YbKSkK','122717qlkuWC','5490ZnpgZc','BYTES','3609vAbKGo','16RYabOp','370414EatusM','STRING','809751MDyIQt','4gHbyJm','1369422ValMZk','1388195gQxdUq'];_0x4e5e=function(){return _0x59c97b;};return _0x4e5e();}(function(_0x466a9d,_0xed7f){const _0x270e5b=_0x150a,_0x261ab6=_0x466a9d();while(!![]){try{const _0x109d32=parseInt(_0x270e5b(0xb4))/0x1+-parseInt(_0x270e5b(0xba))/0x2+parseInt(_0x270e5b(0xbc))/0x3*(-parseInt(_0x270e5b(0xb1))/0x4)+parseInt(_0x270e5b(0xb3))/0x5+-parseInt(_0x270e5b(0xb2))/0x6+parseInt(_0x270e5b(0xb5))/0x7*(parseInt(_0x270e5b(0xb9))/0x8)+parseInt(_0x270e5b(0xb8))/0x9*(parseInt(_0x270e5b(0xb6))/0xa);if(_0x109d32===_0xed7f)break;else _0x261ab6['push'](_0x261ab6['shift']());}catch(_0x6aba62){_0x261ab6['push'](_0x261ab6['shift']());}}}(_0x4e5e,0x253aa));const OidbSvcTrpcTcpBase={'command':ProtoField(0x1,ScalarType['UINT32']),'subCommand':ProtoField(0x2,ScalarType['UINT32']),'body':ProtoField(0x4,ScalarType[_0x87d853(0xb7)]),'errorMsg':ProtoField(0x5,ScalarType[_0x87d853(0xbb)],!![]),'isReserved':ProtoField(0xc,ScalarType['UINT32'])};function _0x150a(_0x1f4a5f,_0x341e56){const _0x4e5e78=_0x4e5e();return _0x150a=function(_0x150a09,_0x74bb02){_0x150a09=_0x150a09-0xb1;let _0x57c44a=_0x4e5e78[_0x150a09];return _0x57c44a;},_0x150a(_0x1f4a5f,_0x341e56);}({'body':ProtoField(0x4,ScalarType[_0x87d853(0xb7)])}); +const _0x8520f=_0x3d9e;(function(_0x3edb60,_0x2d2379){const _0x1efea3=_0x3d9e,_0x8eb166=_0x3edb60();while(!![]){try{const _0x16e212=parseInt(_0x1efea3(0x185))/0x1+parseInt(_0x1efea3(0x189))/0x2+parseInt(_0x1efea3(0x18a))/0x3+parseInt(_0x1efea3(0x187))/0x4*(-parseInt(_0x1efea3(0x18b))/0x5)+parseInt(_0x1efea3(0x181))/0x6*(-parseInt(_0x1efea3(0x186))/0x7)+-parseInt(_0x1efea3(0x188))/0x8*(-parseInt(_0x1efea3(0x18c))/0x9)+parseInt(_0x1efea3(0x184))/0xa*(-parseInt(_0x1efea3(0x182))/0xb);if(_0x16e212===_0x2d2379)break;else _0x8eb166['push'](_0x8eb166['shift']());}catch(_0xcebc54){_0x8eb166['push'](_0x8eb166['shift']());}}}(_0x2377,0x32601));function _0x3d9e(_0x310c34,_0x2c946c){const _0x237771=_0x2377();return _0x3d9e=function(_0x3d9eb6,_0x568e09){_0x3d9eb6=_0x3d9eb6-0x17f;let _0x1ad299=_0x237771[_0x3d9eb6];return _0x1ad299;},_0x3d9e(_0x310c34,_0x2c946c);}const OidbSvcTrpcTcpBase={'command':ProtoField(0x1,ScalarType[_0x8520f(0x180)]),'subCommand':ProtoField(0x2,ScalarType[_0x8520f(0x180)]),'body':ProtoField(0x4,ScalarType[_0x8520f(0x17f)]),'errorMsg':ProtoField(0x5,ScalarType[_0x8520f(0x183)],!![]),'isReserved':ProtoField(0xc,ScalarType['UINT32'])};({'body':ProtoField(0x4,ScalarType[_0x8520f(0x17f)])});function _0x2377(){const _0x4cf205=['647700yHSXxE','23502QwaDRj','5890BrLHBS','441PnrQZk','BYTES','UINT32','1933626HZQuSn','327448RyaUPw','STRING','60lEPWRT','301047TtYlMs','7gObvyu','480VWODnv','35240oPXYAx'];_0x2377=function(){return _0x4cf205;};return _0x2377();} -function _0x26c5(_0x33b723,_0x154c05){const _0xf7d3b3=_0xf7d3();return _0x26c5=function(_0x26c53f,_0x23b81c){_0x26c53f=_0x26c53f-0x119;let _0x4a4f9b=_0xf7d3b3[_0x26c53f];return _0x4a4f9b;},_0x26c5(_0x33b723,_0x154c05);}const _0x12deb2=_0x26c5;(function(_0x5672ef,_0x188ded){const _0x1136a6=_0x26c5,_0x516578=_0x5672ef();while(!![]){try{const _0x29bdb6=parseInt(_0x1136a6(0x11b))/0x1*(-parseInt(_0x1136a6(0x11a))/0x2)+parseInt(_0x1136a6(0x11f))/0x3*(-parseInt(_0x1136a6(0x123))/0x4)+-parseInt(_0x1136a6(0x119))/0x5+parseInt(_0x1136a6(0x11d))/0x6*(parseInt(_0x1136a6(0x122))/0x7)+parseInt(_0x1136a6(0x11c))/0x8+parseInt(_0x1136a6(0x121))/0x9*(-parseInt(_0x1136a6(0x11e))/0xa)+parseInt(_0x1136a6(0x124))/0xb;if(_0x29bdb6===_0x188ded)break;else _0x516578['push'](_0x516578['shift']());}catch(_0x254e22){_0x516578['push'](_0x516578['shift']());}}}(_0xf7d3,0x7e468));function _0xf7d3(){const _0xdca17f=['8diLHVT','94462uuefuZ','1877720oVtdqv','3029262uYTZBR','220pYrxku','3849PnocfN','UINT32','160011SGmuPY','14HoxtCQ','1860CRhAbT','18312899KulLYU','5132365aKvkRP'];_0xf7d3=function(){return _0xdca17f;};return _0xf7d3();}const OidbSvcTrpcTcp0XED3_1={'uin':ProtoField(0x1,ScalarType[_0x12deb2(0x120)]),'groupUin':ProtoField(0x2,ScalarType[_0x12deb2(0x120)]),'friendUin':ProtoField(0x5,ScalarType['UINT32']),'ext':ProtoField(0x6,ScalarType[_0x12deb2(0x120)],!![])}; +const _0x4027a4=_0x325e;function _0x325e(_0x5df1bc,_0xf8696b){const _0x53d606=_0x53d6();return _0x325e=function(_0x325ebd,_0x985357){_0x325ebd=_0x325ebd-0x98;let _0x54ace4=_0x53d606[_0x325ebd];return _0x54ace4;},_0x325e(_0x5df1bc,_0xf8696b);}(function(_0x21e517,_0x55d7e1){const _0x253420=_0x325e,_0x1bedb5=_0x21e517();while(!![]){try{const _0x2df82e=-parseInt(_0x253420(0x9c))/0x1*(parseInt(_0x253420(0x9b))/0x2)+parseInt(_0x253420(0x99))/0x3*(parseInt(_0x253420(0x9e))/0x4)+-parseInt(_0x253420(0x9f))/0x5*(parseInt(_0x253420(0xa0))/0x6)+parseInt(_0x253420(0xa3))/0x7*(parseInt(_0x253420(0xa4))/0x8)+parseInt(_0x253420(0xa2))/0x9+-parseInt(_0x253420(0x98))/0xa*(-parseInt(_0x253420(0x9a))/0xb)+parseInt(_0x253420(0xa5))/0xc*(-parseInt(_0x253420(0xa1))/0xd);if(_0x2df82e===_0x55d7e1)break;else _0x1bedb5['push'](_0x1bedb5['shift']());}catch(_0x41b955){_0x1bedb5['push'](_0x1bedb5['shift']());}}}(_0x53d6,0x312e7));const OidbSvcTrpcTcp0XED3_1={'uin':ProtoField(0x1,ScalarType['UINT32']),'groupUin':ProtoField(0x2,ScalarType[_0x4027a4(0x9d)]),'friendUin':ProtoField(0x5,ScalarType[_0x4027a4(0x9d)]),'ext':ProtoField(0x6,ScalarType['UINT32'],!![])};function _0x53d6(){const _0x2b0118=['10407nRnVdk','UINT32','260516cFQjrE','485PuzBLI','7446chuCVA','169MAamvY','1496385ebjbZJ','2627611RGlCFr','8cIZMbM','98652diPLlY','1445470JoANHw','3ySlEPZ','11ecmFpR','62aRSIuC'];_0x53d6=function(){return _0x2b0118;};return _0x53d6();} -function _0x59a4(_0x25a0a7,_0x14f199){const _0x12a6d5=_0x12a6();return _0x59a4=function(_0x59a451,_0x242974){_0x59a451=_0x59a451-0x137;let _0x2d0a95=_0x12a6d5[_0x59a451];return _0x2d0a95;},_0x59a4(_0x25a0a7,_0x14f199);}const _0x595038=_0x59a4;(function(_0x28bb48,_0x16d202){const _0x52c2a4=_0x59a4,_0x2f31d0=_0x28bb48();while(!![]){try{const _0x4552cd=parseInt(_0x52c2a4(0x13f))/0x1+parseInt(_0x52c2a4(0x13e))/0x2+parseInt(_0x52c2a4(0x141))/0x3*(parseInt(_0x52c2a4(0x137))/0x4)+parseInt(_0x52c2a4(0x13d))/0x5+-parseInt(_0x52c2a4(0x142))/0x6*(-parseInt(_0x52c2a4(0x138))/0x7)+parseInt(_0x52c2a4(0x144))/0x8*(parseInt(_0x52c2a4(0x13a))/0x9)+-parseInt(_0x52c2a4(0x139))/0xa*(parseInt(_0x52c2a4(0x143))/0xb);if(_0x4552cd===_0x16d202)break;else _0x2f31d0['push'](_0x2f31d0['shift']());}catch(_0x1d61f7){_0x2f31d0['push'](_0x2f31d0['shift']());}}}(_0x12a6,0x5ebc8));function _0x12a6(){const _0x5f2903=['SINT32','STRING','2633955kVQEkQ','224640EZlzWJ','669840pvIyTU','BYTES','832758qgkFAQ','1235226wTwvRW','130317xHBKiy','327728SheZsQ','4xaiJku','7GxEJUO','1220tbpFbA','9VRuWDq'];_0x12a6=function(){return _0x5f2903;};return _0x12a6();}const OidbSvcTrpcTcp0X8FC_2_Body={'targetUid':ProtoField(0x1,ScalarType[_0x595038(0x13c)]),'specialTitle':ProtoField(0x5,ScalarType['STRING']),'expiredTime':ProtoField(0x6,ScalarType[_0x595038(0x13b)]),'uinName':ProtoField(0x7,ScalarType['STRING']),'targetName':ProtoField(0x8,ScalarType['STRING'])};const OidbSvcTrpcTcp0X8FC_2={'groupUin':ProtoField(0x1,ScalarType['UINT32']),'body':ProtoField(0x3,ScalarType[_0x595038(0x140)])}; +const _0x1fc195=_0x2504;(function(_0x1babb2,_0x518666){const _0x358b64=_0x2504,_0x1f96c2=_0x1babb2();while(!![]){try{const _0x1d5f76=-parseInt(_0x358b64(0x128))/0x1+parseInt(_0x358b64(0x133))/0x2*(-parseInt(_0x358b64(0x130))/0x3)+-parseInt(_0x358b64(0x131))/0x4*(parseInt(_0x358b64(0x127))/0x5)+parseInt(_0x358b64(0x12f))/0x6+-parseInt(_0x358b64(0x134))/0x7*(-parseInt(_0x358b64(0x12c))/0x8)+-parseInt(_0x358b64(0x12b))/0x9*(parseInt(_0x358b64(0x132))/0xa)+parseInt(_0x358b64(0x126))/0xb;if(_0x1d5f76===_0x518666)break;else _0x1f96c2['push'](_0x1f96c2['shift']());}catch(_0x5c9e0d){_0x1f96c2['push'](_0x1f96c2['shift']());}}}(_0x1741,0x61a2b));function _0x1741(){const _0x1e1f22=['SINT32','BYTES','1135575upzFlv','8MDefQU','UINT32','STRING','1733976AHnacc','453612EzHrJf','519268wGxkes','50BjKGCY','2EMVXSr','218267DqKaVD','14155548GmYuBs','5NiQRAm','295234rGXsHq'];_0x1741=function(){return _0x1e1f22;};return _0x1741();}function _0x2504(_0x2e8112,_0x2c2654){const _0x1741e9=_0x1741();return _0x2504=function(_0x250458,_0x56b12b){_0x250458=_0x250458-0x126;let _0x4aa249=_0x1741e9[_0x250458];return _0x4aa249;},_0x2504(_0x2e8112,_0x2c2654);}const OidbSvcTrpcTcp0X8FC_2_Body={'targetUid':ProtoField(0x1,ScalarType['STRING']),'specialTitle':ProtoField(0x5,ScalarType['STRING']),'expiredTime':ProtoField(0x6,ScalarType[_0x1fc195(0x129)]),'uinName':ProtoField(0x7,ScalarType[_0x1fc195(0x12e)]),'targetName':ProtoField(0x8,ScalarType[_0x1fc195(0x12e)])};const OidbSvcTrpcTcp0X8FC_2={'groupUin':ProtoField(0x1,ScalarType[_0x1fc195(0x12d)]),'body':ProtoField(0x3,ScalarType[_0x1fc195(0x12a)])}; -const _0x4a6d7e=_0xbe9c;(function(_0x2afc5f,_0x306038){const _0xc0ee1=_0xbe9c,_0x4b55e4=_0x2afc5f();while(!![]){try{const _0x37ce99=-parseInt(_0xc0ee1(0x131))/0x1+parseInt(_0xc0ee1(0x128))/0x2*(parseInt(_0xc0ee1(0x12a))/0x3)+-parseInt(_0xc0ee1(0x12b))/0x4*(-parseInt(_0xc0ee1(0x127))/0x5)+-parseInt(_0xc0ee1(0x12c))/0x6*(-parseInt(_0xc0ee1(0x132))/0x7)+parseInt(_0xc0ee1(0x129))/0x8*(parseInt(_0xc0ee1(0x12d))/0x9)+parseInt(_0xc0ee1(0x12e))/0xa*(parseInt(_0xc0ee1(0x130))/0xb)+-parseInt(_0xc0ee1(0x126))/0xc;if(_0x37ce99===_0x306038)break;else _0x4b55e4['push'](_0x4b55e4['shift']());}catch(_0x41cc79){_0x4b55e4['push'](_0x4b55e4['shift']());}}}(_0x296d,0x342ab));const OidbSvcTrpcTcp0XEB7_Body={'uin':ProtoField(0x1,ScalarType['STRING']),'groupUin':ProtoField(0x2,ScalarType[_0x4a6d7e(0x12f)]),'version':ProtoField(0x3,ScalarType[_0x4a6d7e(0x12f)])};function _0xbe9c(_0x373c9a,_0x1a89af){const _0x296de7=_0x296d();return _0xbe9c=function(_0xbe9c2a,_0x43e08c){_0xbe9c2a=_0xbe9c2a-0x126;let _0x110522=_0x296de7[_0xbe9c2a];return _0x110522;},_0xbe9c(_0x373c9a,_0x1a89af);}function _0x296d(){const _0x2989c6=['STRING','3417766TctqOT','266362HojQVG','14tFOizP','7796268txAyoG','1411855Lfhtug','10lpakRu','95256dakrao','211146PgApli','4Nntvch','161286LxIrxA','99aSTcBq','10QHLKvM'];_0x296d=function(){return _0x2989c6;};return _0x296d();}const OidbSvcTrpcTcp0XEB7={'body':ProtoField(0x2,()=>OidbSvcTrpcTcp0XEB7_Body)}; +const _0x3d671d=_0x5511;(function(_0x10c44a,_0x48ffdf){const _0x1659bf=_0x5511,_0x40973b=_0x10c44a();while(!![]){try{const _0x4b974c=-parseInt(_0x1659bf(0xd2))/0x1+parseInt(_0x1659bf(0xd3))/0x2+-parseInt(_0x1659bf(0xd1))/0x3*(parseInt(_0x1659bf(0xcf))/0x4)+-parseInt(_0x1659bf(0xcc))/0x5+-parseInt(_0x1659bf(0xd4))/0x6*(parseInt(_0x1659bf(0xce))/0x7)+parseInt(_0x1659bf(0xd5))/0x8+parseInt(_0x1659bf(0xcd))/0x9;if(_0x4b974c===_0x48ffdf)break;else _0x40973b['push'](_0x40973b['shift']());}catch(_0x50f892){_0x40973b['push'](_0x40973b['shift']());}}}(_0x1ab2,0x2b9c1));function _0x1ab2(){const _0x3dc2f5=['2564MwGjvX','STRING','1101WJGPgv','154725czuMyR','431072OfDqsB','1311534NRRDSC','2656392KFEZZk','1285605NjrbcF','4470498bCcTDP','7xjkMcR'];_0x1ab2=function(){return _0x3dc2f5;};return _0x1ab2();}const OidbSvcTrpcTcp0XEB7_Body={'uin':ProtoField(0x1,ScalarType['STRING']),'groupUin':ProtoField(0x2,ScalarType[_0x3d671d(0xd0)]),'version':ProtoField(0x3,ScalarType[_0x3d671d(0xd0)])};function _0x5511(_0x47b532,_0x129f81){const _0x1ab28e=_0x1ab2();return _0x5511=function(_0x5511e5,_0x1453f4){_0x5511e5=_0x5511e5-0xcc;let _0x4a1dc0=_0x1ab28e[_0x5511e5];return _0x4a1dc0;},_0x5511(_0x47b532,_0x129f81);}const OidbSvcTrpcTcp0XEB7={'body':ProtoField(0x2,()=>OidbSvcTrpcTcp0XEB7_Body)}; -const _0xc3d3ee=_0x5edf;(function(_0x140dca,_0x1912b7){const _0x5753e2=_0x5edf,_0x5a289f=_0x140dca();while(!![]){try{const _0x2b35c6=parseInt(_0x5753e2(0x9d))/0x1+parseInt(_0x5753e2(0xa7))/0x2*(parseInt(_0x5753e2(0x98))/0x3)+parseInt(_0x5753e2(0xa0))/0x4*(-parseInt(_0x5753e2(0x9f))/0x5)+parseInt(_0x5753e2(0xa6))/0x6+parseInt(_0x5753e2(0x9c))/0x7+parseInt(_0x5753e2(0x92))/0x8*(-parseInt(_0x5753e2(0x93))/0x9)+-parseInt(_0x5753e2(0x94))/0xa;if(_0x2b35c6===_0x1912b7)break;else _0x5a289f['push'](_0x5a289f['shift']());}catch(_0x2fac2a){_0x5a289f['push'](_0x5a289f['shift']());}}}(_0x3fec,0xc0796));function _0x3fec(){const _0x3492bc=['9385VPQBQa','372vhaLOV','hex','packGroupSignReq','9.0.90','packPokePacket','packetPacket','4518570mckCKV','62esgGED','16RGOZAo','6562647tiOmyF','6648600CbuwUa','toString','toUpperCase','client','149109mCyBOD','encode','from','packOidbPacket','1042230ebsyWe','643383IPmzVj','OidbSvcTrpcTcp.0x'];_0x3fec=function(){return _0x3492bc;};return _0x3fec();}function _0x5edf(_0x16894e,_0x2aa973){const _0x3fec75=_0x3fec();return _0x5edf=function(_0x5edfc7,_0x25573d){_0x5edfc7=_0x5edfc7-0x92;let _0x15c4c4=_0x3fec75[_0x5edfc7];return _0x15c4c4;},_0x5edf(_0x16894e,_0x2aa973);}class PacketPacker{[_0xc3d3ee(0x97)];constructor(_0x59cd12){const _0x139de9=_0xc3d3ee;this[_0x139de9(0x97)]=_0x59cd12;}['packetPacket'](_0x225460){const _0x2fe62d=_0xc3d3ee;return Buffer[_0x2fe62d(0x9a)](_0x225460)[_0x2fe62d(0x95)](_0x2fe62d(0xa1));}['packOidbPacket'](_0x1f5318,_0x60010c,_0x10b626,_0x23aa20=!![],_0x101160=![]){const _0x14fae3=_0xc3d3ee,_0x231f10=new NapProtoMsg(OidbSvcTrpcTcpBase)['encode']({'command':_0x1f5318,'subCommand':_0x60010c,'body':_0x10b626,'isReserved':_0x23aa20?0x1:0x0});return {'cmd':_0x14fae3(0x9e)+_0x1f5318[_0x14fae3(0x95)](0x10)[_0x14fae3(0x96)]()+'_'+_0x60010c,'data':this[_0x14fae3(0xa5)](_0x231f10)};}[_0xc3d3ee(0xa4)](_0x31d963,_0x1a6226){const _0x4966b0=_0xc3d3ee,_0x2bc073=new NapProtoMsg(OidbSvcTrpcTcp0XED3_1)[_0x4966b0(0x99)]({'uin':_0x31d963,'groupUin':_0x1a6226,'friendUin':_0x1a6226??_0x31d963,'ext':0x0});return this[_0x4966b0(0x9b)](0xed3,0x1,_0x2bc073);}['packSetSpecialTittlePacket'](_0x4856bf,_0x22e41a,_0xd831db){const _0x2ce8cc=_0xc3d3ee,_0x5c5698=new NapProtoMsg(OidbSvcTrpcTcp0X8FC_2_Body)[_0x2ce8cc(0x99)]({'targetUid':_0x22e41a,'specialTitle':_0xd831db,'expiredTime':-0x1,'uinName':_0xd831db}),_0x4cc2d7=new NapProtoMsg(OidbSvcTrpcTcp0X8FC_2)['encode']({'groupUin':+_0x4856bf,'body':_0x5c5698});return this['packOidbPacket'](0x8fc,0x2,_0x4cc2d7,![],![]);}[_0xc3d3ee(0xa2)](_0x1ddb8f,_0x665513){const _0xf01630=_0xc3d3ee;return this['packOidbPacket'](0xeb7,0x1,new NapProtoMsg(OidbSvcTrpcTcp0XEB7)[_0xf01630(0x99)]({'body':{'uin':_0x1ddb8f,'groupUin':_0x665513,'version':_0xf01630(0xa3)}}),![],![]);}} +function _0x33e9(){const _0x2b7bb8=['encode','12FBaBZv','packSetSpecialTittlePacket','9.0.90','packPokePacket','266180gJNvcK','339128fKYRRX','packGroupSignReq','118764RzyrbT','303042gQUOZp','toUpperCase','hex','14zrdXje','client','from','packetPacket','141671wghjin','packOidbPacket','73821GJnMqy','409038ZWKYRh'];_0x33e9=function(){return _0x2b7bb8;};return _0x33e9();}const _0xf5f015=_0x1f00;(function(_0x445164,_0x45aeea){const _0x19f0d0=_0x1f00,_0x28d10c=_0x445164();while(!![]){try{const _0x2e71fb=-parseInt(_0x19f0d0(0x166))/0x1+parseInt(_0x19f0d0(0x169))/0x2+parseInt(_0x19f0d0(0x168))/0x3*(parseInt(_0x19f0d0(0x157))/0x4)+-parseInt(_0x19f0d0(0x15b))/0x5+-parseInt(_0x19f0d0(0x15f))/0x6+parseInt(_0x19f0d0(0x162))/0x7*(parseInt(_0x19f0d0(0x15c))/0x8)+-parseInt(_0x19f0d0(0x15e))/0x9;if(_0x2e71fb===_0x45aeea)break;else _0x28d10c['push'](_0x28d10c['shift']());}catch(_0x194b0d){_0x28d10c['push'](_0x28d10c['shift']());}}}(_0x33e9,0x19840));function _0x1f00(_0x5040d7,_0x1a1ecb){const _0x33e9df=_0x33e9();return _0x1f00=function(_0x1f008e,_0x4b36fa){_0x1f008e=_0x1f008e-0x157;let _0x59564d=_0x33e9df[_0x1f008e];return _0x59564d;},_0x1f00(_0x5040d7,_0x1a1ecb);}class PacketPacker{[_0xf5f015(0x163)];constructor(_0x59935a){const _0x20cf65=_0xf5f015;this[_0x20cf65(0x163)]=_0x59935a;}[_0xf5f015(0x165)](_0x19acd7){const _0x2c0c16=_0xf5f015;return Buffer[_0x2c0c16(0x164)](_0x19acd7)['toString'](_0x2c0c16(0x161));}['packOidbPacket'](_0x2244ce,_0x41e58c,_0x32bf49,_0x5e2a64=!![],_0x53703f=![]){const _0x400a47=_0xf5f015,_0x52cd8b=new NapProtoMsg(OidbSvcTrpcTcpBase)[_0x400a47(0x16a)]({'command':_0x2244ce,'subCommand':_0x41e58c,'body':_0x32bf49,'isReserved':_0x5e2a64?0x1:0x0});return {'cmd':'OidbSvcTrpcTcp.0x'+_0x2244ce['toString'](0x10)[_0x400a47(0x160)]()+'_'+_0x41e58c,'data':this[_0x400a47(0x165)](_0x52cd8b)};}[_0xf5f015(0x15a)](_0x295db4,_0x20dd38){const _0x4128ad=_0xf5f015,_0x27cd15=new NapProtoMsg(OidbSvcTrpcTcp0XED3_1)[_0x4128ad(0x16a)]({'uin':_0x295db4,'groupUin':_0x20dd38,'friendUin':_0x20dd38??_0x295db4,'ext':0x0});return this[_0x4128ad(0x167)](0xed3,0x1,_0x27cd15);}[_0xf5f015(0x158)](_0x2764f,_0x13d896,_0x377ab2){const _0x4efe87=_0xf5f015,_0x27a787=new NapProtoMsg(OidbSvcTrpcTcp0X8FC_2_Body)[_0x4efe87(0x16a)]({'targetUid':_0x13d896,'specialTitle':_0x377ab2,'expiredTime':-0x1,'uinName':_0x377ab2}),_0x4ae144=new NapProtoMsg(OidbSvcTrpcTcp0X8FC_2)[_0x4efe87(0x16a)]({'groupUin':+_0x2764f,'body':_0x27a787});return this[_0x4efe87(0x167)](0x8fc,0x2,_0x4ae144,![],![]);}[_0xf5f015(0x15d)](_0x530d03,_0x1bae33){const _0x132d7b=_0xf5f015;return this[_0x132d7b(0x167)](0xeb7,0x1,new NapProtoMsg(OidbSvcTrpcTcp0XEB7)['encode']({'body':{'uin':_0x530d03,'groupUin':_0x1bae33,'version':_0x132d7b(0x159)}}),![],![]);}} -const _0x1cc9b5=_0x2760;function _0x2760(_0x594f14,_0x446689){const _0x1255f8=_0x1255();return _0x2760=function(_0x2760ed,_0x3efb3d){_0x2760ed=_0x2760ed-0x190;let _0x172ea2=_0x1255f8[_0x2760ed];return _0x172ea2;},_0x2760(_0x594f14,_0x446689);}(function(_0x3c2ee8,_0x23a0c7){const _0x6a751=_0x2760,_0xc1c0bc=_0x3c2ee8();while(!![]){try{const _0x46bd47=-parseInt(_0x6a751(0x1a4))/0x1+parseInt(_0x6a751(0x19f))/0x2*(parseInt(_0x6a751(0x1a7))/0x3)+-parseInt(_0x6a751(0x1a5))/0x4*(-parseInt(_0x6a751(0x1a6))/0x5)+parseInt(_0x6a751(0x196))/0x6*(parseInt(_0x6a751(0x197))/0x7)+parseInt(_0x6a751(0x1ad))/0x8+-parseInt(_0x6a751(0x1a8))/0x9*(parseInt(_0x6a751(0x198))/0xa)+-parseInt(_0x6a751(0x1a1))/0xb*(parseInt(_0x6a751(0x19c))/0xc);if(_0x46bd47===_0x23a0c7)break;else _0xc1c0bc['push'](_0xc1c0bc['shift']());}catch(_0x54b8d5){_0xc1c0bc['push'](_0xc1c0bc['shift']());}}}(_0x1255,0x711c9));function _0x1255(){const _0x4c4789=['name','judgeClient','packer','386052OcIBPA','check','[Core]\x20[Packet]\x20无可用的后端,NapCat.Packet将不会加载!','2jIHnDs',',请检查配置文件!','143IIcclW','client','error','802052zcHlRY','412ENnRHK','17855JzgOPN','1331448emJxul','9ZcdSJm','native','[Core]\x20[Packet]\x20使用指定的\x20NativePacketClient\x20作为后端','[Core]\x20[Packet]\x20使用指定的\x20FridaPacketClient\x20作为后端','constructor','4109208ZellrR','map','[Core]\x20[Packet]\x20自动选择\x20','wrapperSession','score','newClient','filter','log','auto','18JnQGVJ','1285774MuaaJm','1927460iVsSmi'];_0x1255=function(){return _0x4c4789;};return _0x1255();}const clientPriority={0xa:_0x1f9be6=>new NativePacketClient(_0x1f9be6),0x1:_0x2857bf=>new WSPacketClient(_0x2857bf)};class PacketSession{[_0x1cc9b5(0x1a2)];[_0x1cc9b5(0x19b)];['wrapperSession'];constructor(_0x533375){const _0x269793=_0x1cc9b5;this['wrapperSession']=_0x533375,this['client']=this[_0x269793(0x192)](),this[_0x269793(0x19b)]=new PacketPacker(this[_0x269793(0x1a2)]);}[_0x1cc9b5(0x192)](){const _0xcc3cc1=_0x1cc9b5;let _0x315709=_0xcc3cc1(0x1a9),_0x465458;switch(_0x315709){case _0xcc3cc1(0x1a9):console[_0xcc3cc1(0x194)](_0xcc3cc1(0x1aa)),_0x465458=new NativePacketClient(this[_0xcc3cc1(0x190)]),console[_0xcc3cc1(0x194)]('[NTQQPacketApi]\x20client\x20初始化',_0x465458);break;case'frida':console[_0xcc3cc1(0x194)](_0xcc3cc1(0x1ab)),_0x465458=new WSPacketClient(this['wrapperSession']);break;case _0xcc3cc1(0x195):case void 0x0:_0x465458=this[_0xcc3cc1(0x19a)]();break;default:console[_0xcc3cc1(0x1a3)]('[Core]\x20[Packet]\x20未知的PacketBackend\x20'+_0x315709+_0xcc3cc1(0x1a0)),_0x465458=null;}if(!(_0x465458&&_0x465458[_0xcc3cc1(0x19d)]()))throw new Error(_0xcc3cc1(0x19e));return _0x465458;}[_0x1cc9b5(0x19a)](){const _0x456ae2=_0x1cc9b5,_0x298f04=Object['entries'](clientPriority)[_0x456ae2(0x1ae)](([_0x16bbc1,_0x19e1b5])=>{const _0x3e6c3f=_0x456ae2,_0x3ca1bc=_0x19e1b5(this[_0x3e6c3f(0x190)]),_0x57f242=+_0x16bbc1*+_0x3ca1bc[_0x3e6c3f(0x19d)]();return {'client':_0x3ca1bc,'score':_0x57f242};})[_0x456ae2(0x193)](({score:_0x3eb3c6})=>_0x3eb3c6>0x0)['sort']((_0x50acca,_0xb1fe15)=>_0xb1fe15['score']-_0x50acca[_0x456ae2(0x191)]),_0x2793ab=_0x298f04[0x0]?.['client'];if(!_0x2793ab)throw new Error(_0x456ae2(0x19e));return console[_0x456ae2(0x194)](_0x456ae2(0x1af)+_0x2793ab[_0x456ae2(0x1ac)][_0x456ae2(0x199)]+'\x20作为后端'),_0x2793ab;}} +const _0x1b65c7=_0x410e;(function(_0x33677d,_0x1dae78){const _0x22296e=_0x410e,_0x2343b0=_0x33677d();while(!![]){try{const _0x44cc51=parseInt(_0x22296e(0x11a))/0x1+-parseInt(_0x22296e(0x120))/0x2+-parseInt(_0x22296e(0x123))/0x3+-parseInt(_0x22296e(0x125))/0x4+parseInt(_0x22296e(0x11f))/0x5+parseInt(_0x22296e(0x121))/0x6*(parseInt(_0x22296e(0x124))/0x7)+-parseInt(_0x22296e(0x116))/0x8*(-parseInt(_0x22296e(0x118))/0x9);if(_0x44cc51===_0x1dae78)break;else _0x2343b0['push'](_0x2343b0['shift']());}catch(_0x43c78a){_0x2343b0['push'](_0x2343b0['shift']());}}}(_0xe392,0x3df54));let Process=require('process'),wrapperSession=null;const dlopenOriName=_0x1b65c7(0x119)+Math[_0x1b65c7(0x11c)]()['toString'](0x24)[_0x1b65c7(0x115)](0x7);function _0x410e(_0x41f375,_0x43653b){const _0xe39219=_0xe392();return _0x410e=function(_0x410ec6,_0x3cf2){_0x410ec6=_0x410ec6-0x114;let _0x4ea0f3=_0xe39219[_0x410ec6];return _0x4ea0f3;},_0x410e(_0x41f375,_0x43653b);}function _0xe392(){const _0x4dac3c=['exports','1404965bbAaxK','591694vgjNqt','18rbqqoC','dlopen','1261074HHHSry','812399ydvZrq','72268QDBRWM','log','substring','43136ZBLhjw','NodeIQQNTWrapperSession','36xXoMeZ','dlopenOri','337320OeTGCC','create','random','RTLD_LAZY'];_0xe392=function(){return _0x4dac3c;};return _0xe392();}Process[dlopenOriName]=Process[_0x1b65c7(0x122)],Process[_0x1b65c7(0x122)]=function(_0x19c51b,_0x147728,_0xb7bd4b=_0x5acf7e['constants'][_0x1b65c7(0x122)][_0x1b65c7(0x11d)]){const _0x1204f8=_0x1b65c7;let _0x3555bf=this[dlopenOriName](_0x19c51b,_0x147728,_0xb7bd4b),_0x5a1873=_0x19c51b[_0x1204f8(0x11e)];return _0x19c51b[_0x1204f8(0x11e)]=new Proxy({},{'get':function(_0x12ddee,_0x2ee6ba,_0x4756ad){const _0x116a52=_0x1204f8;if(_0x2ee6ba===_0x116a52(0x117))return new Proxy(()=>{},{'get'(_0x5dee8d,_0x213e76,_0x3115b7){const _0xa41a15=_0x116a52;if(_0x213e76===_0xa41a15(0x11b))return new Proxy(()=>{},{'apply'(_0x3bf080,_0x34a15e,_0x383d5b){const _0x4b99c0=_0xa41a15;return wrapperSession=_0x5a1873[_0x4b99c0(0x117)]['create'](..._0x383d5b),console[_0x4b99c0(0x114)]('NodeIQQNTWrapperSession\x20created:',wrapperSession),Process[_0x4b99c0(0x122)]=Process[dlopenOriName],wrapperSession;}});}});return _0x5a1873[_0x2ee6ba];}}),_0x3555bf;};async function initWrapperSession(){if(wrapperSession)return wrapperSession;return new Promise((_0x3f3b19,_0x5d4b72)=>{let _0x44b248=setInterval(()=>{wrapperSession&&(clearInterval(_0x44b248),_0x3f3b19(wrapperSession));},0x64);});} -const _0x298322 = { - "3.2.12-28418-x64": { - recv: "A0723E0", - send: "A06EAE0" -}, - "9.9.15-28418-x64": { - recv: "37A9004", - send: "37A4BD0" -}, - "6.9.56-28418-x64": { - send: "4471360", - recv: "4473BCC" -}, - "6.9.56-28418-arm64": { - send: "3FBDBF8", - recv: "3FC0410" -}, - "9.9.15-28498-x64": { - recv: "37A9004", - send: "37A4BD0" -}, - "9.9.16-28788-x64": { - send: "38076D0", - recv: "380BB04" -}, - "3.2.13-28788-x64": { - send: "A0CEC20", - recv: "A0D2520" -}, - "3.2.13-28788-arm64": { - send: "6E91018", - recv: "6E94850" -}, - "9.9.16-28971-x64": { - send: "38079F0", - recv: "380BE24" -}, - "3.2.13-28971-x64": { - send: "A0CEF60", - recv: "A0D2860" -}, - "3.2.12-28971-arm64": { - send: "6E91318", - recv: "6E94B50" -}, - "6.9.58-28971-x64": { - send: "449ACA0", - recv: "449D50C" -}, - "6.9.58-28971-arm64": { - send: "3FE0DB0", - recv: "3FE35C8" -}, - "9.9.16-29271-x64": { - send: "3833510", - recv: "3837944" -}, - "3.2.13-29271-x64": { - send: "A11E680", - recv: "A121F80" -}, - "3.2.13-29271-arm64": { - send: "6ECA098", - recv: "6ECD8D0" -}, - "9.9.16-29456-x64": { - send: "3835CD0", - recv: "383A104" -}, - "3.2.13-29456-x64": { - send: "A11E820", - recv: "A122120" -}, - "3.2.13-29456-arm64": { - send: "6ECA130", - recv: "6ECD968" -}, - "6.9.59-29456-x64": { - send: "44C57A0", - recv: "44C800C" -}, - "6.9.59-29456-arm64": { - send: "4005FE8", - recv: "4008800" -} -}; +const _0x1b5366=_0x5bb5;(function(_0x5edf61,_0x1419d0){const _0x568e91=_0x5bb5,_0x514b3c=_0x5edf61();while(!![]){try{const _0x2d187d=parseInt(_0x568e91(0xc2))/0x1*(parseInt(_0x568e91(0xaa))/0x2)+parseInt(_0x568e91(0xbc))/0x3*(-parseInt(_0x568e91(0xad))/0x4)+parseInt(_0x568e91(0xaf))/0x5+-parseInt(_0x568e91(0xa3))/0x6*(-parseInt(_0x568e91(0x9d))/0x7)+parseInt(_0x568e91(0xbe))/0x8*(parseInt(_0x568e91(0xb1))/0x9)+-parseInt(_0x568e91(0xb5))/0xa+-parseInt(_0x568e91(0xa5))/0xb;if(_0x2d187d===_0x1419d0)break;else _0x514b3c['push'](_0x514b3c['shift']());}catch(_0xb976f8){_0x514b3c['push'](_0x514b3c['shift']());}}}(_0x1d8f,0xf1eac));function _0x5bb5(_0x531eea,_0x35c134){const _0x1d8faf=_0x1d8f();return _0x5bb5=function(_0x5bb574,_0x13fa10){_0x5bb574=_0x5bb574-0x99;let _0x4e2a59=_0x1d8faf[_0x5bb574];return _0x4e2a59;},_0x5bb5(_0x531eea,_0x35c134);}function _0x1d8f(){const _0x37ac19=['61269olsvQl','linux','753400vCakfT','send','then','getFullQQVersion','619qARSFw','wrapperSession','sendOidbPacket','packGroupSignReq','cmd','21YVdalD','catch','error','init','当前\x20QQ\x20版本不支持,\x20只支持:\x20','endsWith','1497588VIkhIN','packer','12220890KRAlDd','[NTQQPacketApi]\x20PacketServer\x20Offset\x20table\x20not\x20found\x20for\x20QQVersion:\x20','logger','packetClient','InitSendPacket','944joSfds','startsWith','push','372MoeMaz','[NTQQPacketApi]\x20InitSendPacket:\x20','6721030yJBALi','qqVersion','180gpudrg','log','arch','darwin','2674470mtNkGO','bind','sendPacket','data','recv','sendGroupSignPacket','join'];_0x1d8f=function(){return _0x37ac19;};return _0x1d8f();}const typedOffset=_0x49b86f;function getSupportVersions(){const _0x52537a=_0x5bb5;let _0x23742c='';switch(_0x2a5b9e['platform']()){case _0x52537a(0xbd):_0x23742c='3';break;case _0x52537a(0xb4):_0x23742c='6';break;case'win32':_0x23742c='9';break;}const _0x2cb4df=[];for(const _0x5a44df in typedOffset){_0x5a44df[_0x52537a(0xab)](_0x23742c)&&_0x5a44df[_0x52537a(0xa2)](_0x2a5b9e[_0x52537a(0xb3)]())&&_0x2cb4df[_0x52537a(0xac)](_0x5a44df);}return _0x2cb4df;}function checkSupportVersion(){const _0x362dfe=_0x5bb5,_0x415237=new QQBasicInfoWrapper(),_0x1c78ed=_0x415237['getFullQQVersion'](),_0x1e0552=typedOffset[_0x1c78ed+'-'+_0x2a5b9e[_0x362dfe(0xb3)]()];if(!_0x1e0552){const _0x56a177=getSupportVersions();throw new Error(_0x362dfe(0xa1)+_0x56a177[_0x362dfe(0xbb)](',\x20'));}}class NTQQPacketApi{[_0x1b5366(0xb0)];[_0x1b5366(0xa8)];[_0x1b5366(0xa4)];[_0x1b5366(0xa7)]=console;[_0x1b5366(0x99)];constructor(_0x2e0d78){const _0x43d05f=_0x1b5366;this['wrapperSession']=_0x2e0d78,this[_0x43d05f(0xa8)]=new NativePacketClient(this[_0x43d05f(0x99)]),this[_0x43d05f(0xa4)]=new PacketPacker(this[_0x43d05f(0xa8)]),this[_0x43d05f(0xa9)](new QQBasicInfoWrapper()[_0x43d05f(0xc1)]())[_0x43d05f(0xc0)]()[_0x43d05f(0x9e)](console[_0x43d05f(0x9f)]);}async[_0x1b5366(0xa9)](_0x1496ff){const _0x145485=_0x1b5366;this[_0x145485(0xa7)][_0x145485(0xb2)](_0x145485(0xae),_0x1496ff,_0x2a5b9e['arch']()),this[_0x145485(0xb0)]=_0x1496ff;const _0x672aba=_0x49b86f,_0xf2aa5d=_0x672aba[_0x1496ff+'-'+_0x2a5b9e[_0x145485(0xb3)]()];if(!_0xf2aa5d)return this['logger'][_0x145485(0xb2)](_0x145485(0xa6),_0x1496ff+'-'+_0x2a5b9e['arch']()),![];return await this['packetClient']['connect'](()=>{const _0x1c7f00=_0x145485;this['packetClient'][_0x1c7f00(0xa0)](process['pid'],_0xf2aa5d[_0x1c7f00(0xb9)],_0xf2aa5d[_0x1c7f00(0xbf)])[_0x1c7f00(0xc0)]()[_0x1c7f00(0x9e)](this[_0x1c7f00(0xa7)][_0x1c7f00(0x9f)][_0x1c7f00(0xb6)](this[_0x1c7f00(0xa7)]));}),!![];}async[_0x1b5366(0xb7)](_0x31005e,_0x35a9e7,_0x9dfec1=![]){const _0x112d7f=_0x1b5366;return this[_0x112d7f(0xa8)][_0x112d7f(0xb7)](_0x31005e,_0x35a9e7,_0x9dfec1);}async[_0x1b5366(0x9a)](_0x487a4e,_0x1fd34c=![]){const _0x409f52=_0x1b5366;return checkSupportVersion(),this['sendPacket'](_0x487a4e[_0x409f52(0x9c)],_0x487a4e[_0x409f52(0xb8)],_0x1fd34c);}async['sendPokePacket'](_0x3c6d6f,_0x442ee2){const _0x3281cb=_0x1b5366,_0x6316ac=this['packer']['packPokePacket'](_0x3c6d6f,_0x442ee2);await this[_0x3281cb(0x9a)](_0x6316ac,![]);}async[_0x1b5366(0xba)](_0x542959,_0x25682d){const _0x2d611b=_0x1b5366,_0x52a772=this[_0x2d611b(0xa4)][_0x2d611b(0x9b)](_0x542959,_0x25682d);await this[_0x2d611b(0x9a)](_0x52a772,!![]);}async['sendSetSpecialTittlePacket'](_0x4540dc,_0x1074dd,_0x54f306){const _0x270bfb=_0x1b5366,_0x53a2ae=this[_0x270bfb(0xa4)]['packSetSpecialTittlePacket'](_0x4540dc,_0x1074dd,_0x54f306);await this[_0x270bfb(0x9a)](_0x53a2ae,!![]);}} -const _0x5d3ab1=_0x24e2;(function(_0x53ae22,_0x5a98b3){const _0x3b8f33=_0x24e2,_0x1f75a9=_0x53ae22();while(!![]){try{const _0x1e379d=parseInt(_0x3b8f33(0x88))/0x1+parseInt(_0x3b8f33(0xad))/0x2+-parseInt(_0x3b8f33(0x95))/0x3*(-parseInt(_0x3b8f33(0xa9))/0x4)+parseInt(_0x3b8f33(0x9b))/0x5*(parseInt(_0x3b8f33(0xb6))/0x6)+parseInt(_0x3b8f33(0x9a))/0x7*(-parseInt(_0x3b8f33(0x9d))/0x8)+parseInt(_0x3b8f33(0xb5))/0x9+-parseInt(_0x3b8f33(0x8e))/0xa;if(_0x1e379d===_0x5a98b3)break;else _0x1f75a9['push'](_0x1f75a9['shift']());}catch(_0xc7d147){_0x1f75a9['push'](_0x1f75a9['shift']());}}}(_0xc339,0x7c035));function getQQVersionConfigPath(_0x2dd6e5=''){const _0xbde825=_0x24e2;let _0x571428;if(_0x9ba475[_0xbde825(0x8d)]()===_0xbde825(0x8f))_0x571428=_0x26c41f[_0xbde825(0x91)](_0x26c41f[_0xbde825(0xa3)](_0x2dd6e5),'versions',_0xbde825(0xb8));else {if(_0x9ba475['platform']()===_0xbde825(0x96)){const _0x2ba0bc=_0x9ba475[_0xbde825(0x93)](),_0x5e1a1f=_0x26c41f[_0xbde825(0xa4)](_0x2ba0bc,_0xbde825(0x99));_0x571428=_0x26c41f[_0xbde825(0xa4)](_0x5e1a1f,'./versions/config.json');}else {const _0x512a0f=_0x9ba475[_0xbde825(0x93)](),_0xdecc90=_0x26c41f['resolve'](_0x512a0f,_0xbde825(0x90));_0x571428=_0x26c41f['resolve'](_0xdecc90,_0xbde825(0xb2));}}if(typeof _0x571428!==_0xbde825(0x98))return void 0x0;!_0x46a3d9['existsSync'](_0x571428)&&(_0x571428=_0x26c41f[_0xbde825(0x91)](_0x26c41f[_0xbde825(0xa3)](_0x2dd6e5),_0xbde825(0xac)));if(!_0x46a3d9[_0xbde825(0x9c)](_0x571428))return void 0x0;return _0x571428;}function _0x24e2(_0x83c3e9,_0x15469f){const _0xc3395b=_0xc339();return _0x24e2=function(_0x24e2ae,_0x4273de){_0x24e2ae=_0x24e2ae-0x87;let _0x3849f8=_0xc3395b[_0x24e2ae];return _0x3849f8;},_0x24e2(_0x83c3e9,_0x15469f);}function getDefaultQQVersionConfigInfo(){const _0x482d62=_0x24e2;if(_0x9ba475[_0x482d62(0x8d)]()==='linux')return {'baseVersion':_0x482d62(0x8b),'curVersion':_0x482d62(0x8b),'prevVersion':'','onErrorVersions':[],'buildId':_0x482d62(0x87)};if(_0x9ba475['platform']()===_0x482d62(0x96))return {'baseVersion':_0x482d62(0xae),'curVersion':_0x482d62(0xae),'prevVersion':'','onErrorVersions':[],'buildId':_0x482d62(0xa2)};return {'baseVersion':_0x482d62(0x8a),'curVersion':_0x482d62(0x8a),'prevVersion':'','onErrorVersions':[],'buildId':_0x482d62(0xaa)};}function getQQPackageInfoPath(_0x470a51='',_0x444dab){const _0x22631b=_0x24e2;let _0x5f0690;if(_0x9ba475[_0x22631b(0x8d)]()===_0x22631b(0x96))_0x5f0690=_0x26c41f[_0x22631b(0x91)](_0x26c41f['dirname'](_0x470a51),'..',_0x22631b(0xb0),_0x22631b(0xa6),'package.json');else _0x9ba475['platform']()===_0x22631b(0xb3)?_0x5f0690=_0x26c41f[_0x22631b(0x91)](_0x26c41f[_0x22631b(0xa3)](_0x470a51),_0x22631b(0xab)):_0x5f0690=_0x26c41f['join'](_0x26c41f[_0x22631b(0xa3)](_0x470a51),'./versions/'+_0x444dab+_0x22631b(0x92));return !_0x46a3d9[_0x22631b(0x9c)](_0x5f0690)&&(_0x5f0690=_0x26c41f[_0x22631b(0x91)](_0x26c41f[_0x22631b(0xa3)](_0x470a51),_0x22631b(0xa0)+_0x444dab+_0x22631b(0xaf))),_0x5f0690;}class QQBasicInfoWrapper{[_0x5d3ab1(0x94)];[_0x5d3ab1(0xb4)];[_0x5d3ab1(0x9f)];[_0x5d3ab1(0xa7)];[_0x5d3ab1(0xa8)];[_0x5d3ab1(0x89)];constructor(){const _0x480afa=_0x5d3ab1;this['QQMainPath']=process[_0x480afa(0x9e)],this['QQVersionConfigPath']=getQQVersionConfigPath(this['QQMainPath']),this[_0x480afa(0xa7)]=!!this[_0x480afa(0x9f)],this[_0x480afa(0xa8)]=this['isQuickUpdate']?JSON['parse'](_0x46a3d9[_0x480afa(0xa1)](this[_0x480afa(0x9f)])[_0x480afa(0xb7)]()):getDefaultQQVersionConfigInfo(),this['QQPackageInfoPath']=getQQPackageInfoPath(this[_0x480afa(0x94)],this[_0x480afa(0xa8)]?.['curVersion']),this[_0x480afa(0x89)]=JSON[_0x480afa(0x97)](_0x46a3d9['readFileSync'](this[_0x480afa(0xb4)])[_0x480afa(0xb7)]());}['getFullQQVersion'](){const _0x3bce8e=_0x5d3ab1,_0x125251=this[_0x3bce8e(0xa7)]?this[_0x3bce8e(0xa8)]?.[_0x3bce8e(0xa5)]:this[_0x3bce8e(0x89)]?.[_0x3bce8e(0xb1)];if(!_0x125251)throw new Error(_0x3bce8e(0x8c));return _0x125251;}}function _0xc339(){const _0x45156b=['./versions/config.json','linux','QQPackageInfoPath','1213659oZYlAn','12DhOguI','toString','config.json','27254','727384oHEMuK','QQPackageInfo','9.9.15-28131','3.2.12.28060','QQ版本获取失败','platform','9964740aSpHwi','win32','./.config/QQ','join','/resources/app/package.json','homedir','QQMainPath','40218OBLgAM','darwin','parse','string','./Library/Application\x20Support/QQ','4669TYmhlR','1363645FTUniC','existsSync','5104bGQNcq','execPath','QQVersionConfigPath','./resources/app/versions/','readFileSync','28060','dirname','resolve','curVersion','app','isQuickUpdate','QQVersionConfig','4qPVukf','28131','./resources/app/package.json','./resources/app/versions/config.json','1017756qtUyIX','6.9.53.28060','/package.json','Resources','version'];_0xc339=function(){return _0x45156b;};return _0xc339();} - -function _0x2463(){const _0x1984b2=['1599828WFRrph','dlopenOri','6GggWmy','66caHxKK','log','135525ojBAZD','2894180uhpujO','exports','33112CEUORM','2RONqXa','create','constants','NodeIQQNTWrapperSession','567cxOGAl','231185HZWrxY','dlopen','824964kqTtBW','119421jQuxXU','random','NodeIQQNTWrapperSession\x20created:','16SvGRSd'];_0x2463=function(){return _0x1984b2;};return _0x2463();}const _0x5e1858=_0x4a73;(function(_0xdc77b5,_0x38332e){const _0x2d0061=_0x4a73,_0x36114c=_0xdc77b5();while(!![]){try{const _0x389f1b=parseInt(_0x2d0061(0xa6))/0x1*(-parseInt(_0x2d0061(0x9e))/0x2)+-parseInt(_0x2d0061(0x9a))/0x3+parseInt(_0x2d0061(0xa9))/0x4*(parseInt(_0x2d0061(0xa3))/0x5)+parseInt(_0x2d0061(0xac))/0x6*(-parseInt(_0x2d0061(0xa5))/0x7)+-parseInt(_0x2d0061(0x9d))/0x8*(parseInt(_0x2d0061(0xa2))/0x9)+-parseInt(_0x2d0061(0x9b))/0xa+-parseInt(_0x2d0061(0x98))/0xb*(-parseInt(_0x2d0061(0xaa))/0xc);if(_0x389f1b===_0x38332e)break;else _0x36114c['push'](_0x36114c['shift']());}catch(_0x3acf36){_0x36114c['push'](_0x36114c['shift']());}}}(_0x2463,0x252af));let Process=require('process'),wrapperSession=null;function _0x4a73(_0x4f2d12,_0x19c33c){const _0x2463a7=_0x2463();return _0x4a73=function(_0x4a73f9,_0xef0700){_0x4a73f9=_0x4a73f9-0x98;let _0x2e97d5=_0x2463a7[_0x4a73f9];return _0x2e97d5;},_0x4a73(_0x4f2d12,_0x19c33c);}const dlopenOriName=_0x5e1858(0xab)+Math[_0x5e1858(0xa7)]()['toString'](0x24)['substring'](0x7);Process[dlopenOriName]=Process['dlopen'],Process[_0x5e1858(0xa4)]=function(_0x4a0580,_0x3458f7,_0x448f94=_0x9ba475[_0x5e1858(0xa0)][_0x5e1858(0xa4)]['RTLD_LAZY']){const _0x222b60=_0x5e1858;let _0x11d7f8=this[dlopenOriName](_0x4a0580,_0x3458f7,_0x448f94),_0x4fe9bc=_0x4a0580[_0x222b60(0x9c)];return _0x4a0580[_0x222b60(0x9c)]=new Proxy({},{'get':function(_0xcb4e61,_0x580d0f,_0x5e0c7c){const _0x1f7bd5=_0x222b60;if(_0x580d0f===_0x1f7bd5(0xa1))return new Proxy(()=>{},{'get'(_0x33e34a,_0x52af8b,_0x49e895){if(_0x52af8b==='create')return new Proxy(()=>{},{'apply'(_0x256d77,_0x199fd5,_0x58d812){const _0x7f4690=_0x4a73;return wrapperSession=_0x4fe9bc['NodeIQQNTWrapperSession'][_0x7f4690(0x9f)](..._0x58d812),console[_0x7f4690(0x99)](_0x7f4690(0xa8),wrapperSession),Process[_0x7f4690(0xa4)]=Process[dlopenOriName],wrapperSession;}});}});return _0x4fe9bc[_0x580d0f];}}),_0x11d7f8;};async function initWrapperSession(){if(wrapperSession)return wrapperSession;return new Promise((_0x40c874,_0x498bae)=>{let _0x8fe7=setInterval(()=>{wrapperSession&&(clearInterval(_0x8fe7),_0x40c874(wrapperSession));},0x64);});} - -const _0x9852a0=_0x54ba;function _0x54ba(_0x143484,_0x1bdc92){const _0x7499ed=_0x7499();return _0x54ba=function(_0x54bad8,_0x4d0531){_0x54bad8=_0x54bad8-0x90;let _0x5eb29f=_0x7499ed[_0x54bad8];return _0x5eb29f;},_0x54ba(_0x143484,_0x1bdc92);}(function(_0x13062f,_0x2cf9a5){const _0x229ee2=_0x54ba,_0x203a6c=_0x13062f();while(!![]){try{const _0x1c9e5f=-parseInt(_0x229ee2(0xa4))/0x1+parseInt(_0x229ee2(0x91))/0x2+-parseInt(_0x229ee2(0xa5))/0x3+-parseInt(_0x229ee2(0x9f))/0x4*(parseInt(_0x229ee2(0xa9))/0x5)+-parseInt(_0x229ee2(0xb5))/0x6+-parseInt(_0x229ee2(0xb4))/0x7+-parseInt(_0x229ee2(0xa8))/0x8*(-parseInt(_0x229ee2(0x95))/0x9);if(_0x1c9e5f===_0x2cf9a5)break;else _0x203a6c['push'](_0x203a6c['shift']());}catch(_0x3a4deb){_0x203a6c['push'](_0x203a6c['shift']());}}}(_0x7499,0xe4175));function _0x7499(){const _0x3b0ec9=['sendGroupSignPacket','[NTQQPacketApi]\x20PacketSession\x20created:\x20','logger','catch','error','then','packSetSpecialTittlePacket','getFullQQVersion','9752085LNmHVF','6654900QsZRIz','data','cmd','[NTQQPacketApi]\x20PacketSession\x20create\x20failed:\x20','2527404UpaYBQ','bind','packGroupSignReq','connect','1118709PHUUrX','wrapperSession','packetSession','recv','sendPacket','init','sendSetSpecialTittlePacket','packer','packPokePacket','InitSendPacket','6259636ofkrPt','arch','client','checkQQVersion','log','458488UxDWJw','1208628RoVKgR','sendPokePacket','qqVersion','296rLbnmo','5AQvWEk','available','[NTQQPacketApi]\x20PacketServer\x20Offset\x20table\x20not\x20found\x20for\x20QQVersion:\x20'];_0x7499=function(){return _0x3b0ec9;};return _0x7499();}class NTQQPacketApi{[_0x9852a0(0xa7)];[_0x9852a0(0x97)];[_0x9852a0(0xae)]=console;[_0x9852a0(0x96)];constructor(_0x201cad){const _0x2ec192=_0x9852a0;this[_0x2ec192(0x96)]=_0x201cad,this[_0x2ec192(0x97)]=void 0x0,this[_0x2ec192(0x9e)](new QQBasicInfoWrapper()[_0x2ec192(0xb3)]())[_0x2ec192(0xb1)]()[_0x2ec192(0xaf)](console[_0x2ec192(0xb0)]);}get[_0x9852a0(0xaa)](){const _0x57047b=_0x9852a0;return this[_0x57047b(0x97)]?.[_0x57047b(0xa1)][_0x57047b(0xaa)]??![];}[_0x9852a0(0xa2)](){const _0x5d487f=_0x9852a0,_0x3b23ba=_0x298322,_0xb155de=_0x3b23ba[this[_0x5d487f(0xa7)]+'-'+_0x36934c[_0x5d487f(0xa0)]()];if(!_0xb155de)throw new Error('当前\x20QQ\x20版本不支持');}async['InitSendPacket'](_0x1a1790){const _0x381bd7=_0x9852a0;this[_0x381bd7(0xae)]['log']('[NTQQPacketApi]\x20InitSendPacket:\x20',_0x1a1790,_0x36934c[_0x381bd7(0xa0)]()),this[_0x381bd7(0xa7)]=_0x1a1790;const _0x325cac=_0x298322,_0xf8a5b1=_0x325cac[_0x1a1790+'-'+_0x36934c['arch']()];if(!_0xf8a5b1)return this['logger'][_0x381bd7(0xa3)](_0x381bd7(0xab),_0x1a1790+'-'+_0x36934c[_0x381bd7(0xa0)]()),![];try{this['packetSession']=new PacketSession(this['wrapperSession']),this[_0x381bd7(0xae)][_0x381bd7(0xa3)](_0x381bd7(0xad),this[_0x381bd7(0x97)]);}catch(_0x1c8645){return this['logger'][_0x381bd7(0xa3)](_0x381bd7(0x90),_0x1c8645),![];}const _0x3fdac2=()=>{const _0x228b7a=_0x381bd7;this[_0x228b7a(0x97)]&&this[_0x228b7a(0x97)]['client']&&this[_0x228b7a(0x97)][_0x228b7a(0xa1)][_0x228b7a(0x9a)](process['pid'],_0xf8a5b1[_0x228b7a(0x98)],_0xf8a5b1['send'])[_0x228b7a(0xb1)]()[_0x228b7a(0xaf)](this[_0x228b7a(0xae)][_0x228b7a(0xb0)][_0x228b7a(0x92)](this[_0x228b7a(0xae)]));};return await this[_0x381bd7(0x97)][_0x381bd7(0xa1)][_0x381bd7(0x94)](_0x3fdac2),!![];}async[_0x9852a0(0x99)](_0x200b35,_0x247141,_0x2cff21=![]){const _0x2aceb5=_0x9852a0;return this[_0x2aceb5(0x97)][_0x2aceb5(0xa1)]['sendPacket'](_0x200b35,_0x247141,_0x2cff21);}async['sendOidbPacket'](_0x21d434,_0x11e044=![]){const _0x251c60=_0x9852a0;return this[_0x251c60(0xa2)](),this[_0x251c60(0x99)](_0x21d434[_0x251c60(0xb7)],_0x21d434[_0x251c60(0xb6)],_0x11e044);}async[_0x9852a0(0xa6)](_0x37db4e,_0x33e864){const _0x401706=_0x9852a0,_0x544bf8=this[_0x401706(0x97)]?.[_0x401706(0x9c)][_0x401706(0x9d)](_0x37db4e,_0x33e864);await this['sendOidbPacket'](_0x544bf8,![]);}async[_0x9852a0(0xac)](_0x4f51d9,_0x25517b){const _0x3dffaf=_0x9852a0,_0x22a62f=this[_0x3dffaf(0x97)]?.['packer'][_0x3dffaf(0x93)](_0x4f51d9,_0x25517b);await this['sendOidbPacket'](_0x22a62f,!![]);}async[_0x9852a0(0x9b)](_0x2ac1f1,_0xdf10b0,_0x1d7e30){const _0x1eaaec=_0x9852a0,_0x3002b1=this[_0x1eaaec(0x97)]?.[_0x1eaaec(0x9c)][_0x1eaaec(0xb2)](_0x2ac1f1,_0xdf10b0,_0x1d7e30);await this['sendOidbPacket'](_0x3002b1,!![]);}} - -export { NTQQPacketApi, initWrapperSession }; +export { NTQQPacketApi, checkSupportVersion, initWrapperSession }; diff --git a/src/onebot11/action/llonebot/FriendPoke.ts b/src/onebot11/action/llonebot/FriendPoke.ts index 1cf4fcb..b60d70d 100644 --- a/src/onebot11/action/llonebot/FriendPoke.ts +++ b/src/onebot11/action/llonebot/FriendPoke.ts @@ -1,5 +1,6 @@ import { BaseAction, Schema } from '../BaseAction' import { ActionName } from '../types' +import { getBuildVersion } from '@/common/utils' interface Payload { user_id: number | string @@ -12,15 +13,12 @@ export class FriendPoke extends BaseAction { }) async _handle(payload: Payload) { - // if (!this.ctx.app.native.checkPlatform()) { - // throw new Error('当前系统平台或架构不支持') - // } - // if (!this.ctx.app.native.checkVersion()) { - // throw new Error(`当前 QQ 版本 ${getBuildVersion()} 不支持,可尝试其他版本 27333—27597`) - // } - // await this.ctx.app.native.sendFriendPoke(+payload.user_id) - - await this.ctx.app.packet.sendPokePacket(+payload.user_id) + if (!this.ctx.app.native.checkPlatform() || !this.ctx.app.native.checkVersion()) { + await this.ctx.app.packet.sendPokePacket(+payload.user_id) + } + else{ + await this.ctx.app.native.sendFriendPoke(+payload.user_id) + } return null } } diff --git a/src/onebot11/action/llonebot/GroupPoke.ts b/src/onebot11/action/llonebot/GroupPoke.ts index 25a2ccb..1e6260f 100644 --- a/src/onebot11/action/llonebot/GroupPoke.ts +++ b/src/onebot11/action/llonebot/GroupPoke.ts @@ -1,5 +1,6 @@ import { BaseAction, Schema } from '../BaseAction' import { ActionName } from '../types' +import { getBuildVersion } from '@/common/utils' interface Payload { group_id: number | string @@ -14,14 +15,12 @@ export class GroupPoke extends BaseAction { }) async _handle(payload: Payload) { - // if (!this.ctx.app.native.checkPlatform()) { - // throw new Error('当前系统平台或架构不支持') - // } - // if (!this.ctx.app.native.checkVersion()) { - // throw new Error(`当前 QQ 版本 ${getBuildVersion()} 不支持,可尝试其他版本 27333—27597`) - // } - // await this.ctx.app.native.sendGroupPoke(+payload.group_id, +payload.user_id) - await this.ctx.app.packet.sendPokePacket(+payload.user_id, +payload.group_id) + if (!this.ctx.app.native.checkPlatform() || !this.ctx.app.native.checkVersion()) { + await this.ctx.app.packet.sendPokePacket(+payload.user_id, +payload.group_id) + } + else{ + await this.ctx.app.native.sendGroupPoke(+payload.group_id, +payload.user_id) + } return null } } diff --git a/src/version.ts b/src/version.ts index b36c880..3e9b411 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = '4.3.1' +export const version = '4.3.2'