const config = { "PATH_IMG_V2_PRO": "https://cdn-image.gandart.com/", "RUN_TYPE": 1, "BOTTOM_LOAD_MORE_THROTTLE": 100, "BASE_API": "https://api.gandart.com/base", "RESALE_API": "https://api.gandart.com/market", "RESALE_API_V2": "https://api2.gandart.com/market/api/v2", "RESALE_API_V3": "https://api2.gandart.com/market/api/v3", "SALE_API": "https://api.gandart.com/read/api", "ORDER_API": "https://api.gandart.com", "WALLET_API": "https://api.gandart.com/api", "HXT_API": "https://api.gandart.com/wallet", "PATH_IMG_V2": "https://cdn-image.gandart.com/", "SAND_RECHARGE_ACTION": "https://cap.sandpay.com.cn/v4/front-electrans/ceas.elec.trans.quick.deposit.apply", "GAME_ElF_API": "https://elf.pentajam.cn/api", "GAME_ELF_URL": "https://elf.pentajam.cn", "CORECENTER_URL": "https://api.gandart.com/corecenter" }; const lk = new ToolKit(`光予支付手`, `GandartPayer`); const GandartConstKey = { // -----通用助手相关的----- Token: 'lkGandartToken', UserData: 'lkGandartUserData', PrivCollectionBrief: 'lkGandartPrivCollectionBrief', PrivCollectionDetail: 'lkGandartPrivCollectionDetail', CollectionName: 'lkGandartCollectionName', CastingId: 'lkGandartCastingId', LimitPrice: 'lkGandartLimitPrice', TransactionRecordId: 'lkGandartTransactionRecordId', CollectionCateLst: 'lkGandartCollectionCateLst', FloatPriceIntaval: 'lkGandartFloatPriceIntaval', IsCollectionWatchLocked: 'lkIsGandartCollectionWatchLocked', PrivWalletListInUse: 'lkGandartPrivWalletListInUse', IsCollectionMaxNumLimit: 'lkGandartIsCollectionMaxNumLimit', CollectionLockMaxNum: 'lkGandartCollectionLockMaxNum', PasswordPlainText: 'lkGandartPasswordPlainText', PrivPayWalletList: 'lkGandartPrivPayWalletList', }; let gandartToken = lk.getVal(GandartConstKey.Token, ''); let gandartUserAgent = `Mozilla/5.0 (iPhone; CPU iPhone OS 16_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Mobile/15E148 Safari/604.1`; const GCommonGandartHeads = { 'Accept': `application/json, text/plain, */*`, 'Origin': `https://www.gandart.com`, 'Accept-Encoding': `gzip, deflate, br`, 'Content-Type': `application/x-www-form-urlencoded;charset=UTF-8`, 'Connection': `keep-alive`, 'Host': `api2.gandart.com`, 'User-Agent': gandartUserAgent, 'Referer': `https://www.gandart.com/`, 'Accept-Language': `zh-CN,zh-Hans;q=0.9`, 'token': gandartToken }; let gandartWalletList = 'A,B,C'; let gandartPasswordPlaintext = ''; if (!lk.isExecComm) { if (!lk.isRequest()) { all(); } } async function all() { let paySuccCnt = await checkTryPayAll(); let hasNeedSendNotify = paySuccCnt > 0 ? true : false; if (hasNeedSendNotify) { lk.msg(``); } lk.done(); } function getMyPasswordPlainText() { let str = lk.getVal(GandartConstKey.PasswordPlainText); let ret = ''; if (!lk.isEmpty(str)) { ret = str; } return ret; } function getMyPayWalletList() { let str = lk.getVal(GandartConstKey.PrivPayWalletList); let ret = 'A,B,C'; if (!lk.isEmpty(str)) { ret = str; } return ret; } async function checkTryPayAll() { gandartPasswordPlaintext = getMyPasswordPlainText(); gandartWalletList = getMyPayWalletList(); let orderLstInfo = await getNftOrderList(0); let orderCnt = orderLstInfo.total; let paySuccCnt = 0; if (orderCnt > 0) { let orderLst = orderLstInfo.rows; if (orderLst.length > 0) { for (let info of orderLst) { let isOk = await checkPay(info.orderNo, info.orderTotal); if (isOk) { paySuccCnt++; } } } else { lk.log('不存在未支付订单'); } } else { lk.log('不存在未支付订单'); } return paySuccCnt; } async function getNftOrderList(status, orderType = 0, page = 1, pageSize = 6) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; // status 0:进行中 1:已完成 2:已取消 let body = `orderNo=&status=${status}&orderType=${orderType}&page=${page}&pageSize=${pageSize}`; let url = { url: `${config.BASE_API}/order/nftorder/list`, headers: headers, body: body }; lk.log(`请求个人订单列表:${body}`); lk.post(url, async (error, _response, data) => { let rows; let total = 0; try { if (error) { lk.log(`获取订单列表数据发生错误`); lk.execFail(); // lk.appendNotifyInfo(`❌获取订单列表失败,请稍后再试`); } else { let info = JSON.parse(data); rows = info.rows; total = info.total || info.recordsTotal; } } catch (e) { lk.log(`获取订单列表数据发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve({ total: total, rows: rows }); } }); } catch (e) { lk.log(`获取订单列表数据发生错误`); lk.logErr(e); resolve({ total: 0 }); } }); } async function checkPay(orderNum, orderTotal) { let tranWalletList = await transactionWalletList(orderNum); let orderInfo = await getOrderEndTime(orderNum); if (orderInfo) { let endDate = new Date(orderInfo.endDate); lk.log(`开始尝试去支付订单[${orderNum}],支付金额${orderTotal},订单截止时间:${orderInfo.endDate}`); if (new Date().getTime() < endDate.getTime()) { lk.log('开始检查钱包是否匹配支付'); let myWalletList = await getMyWalletListDetail(); if (tranWalletList && myWalletList) { let isMateWallet = false; let isPaySuccess = false; for (let w1 of myWalletList) { if (tranWalletList.indexOf(w1.channel) > -1) { let availableMoney = w1.availableMoney; if (availableMoney >= orderTotal) { isMateWallet = true; lk.log(`匹配到钱包${w1.channel}余额[${availableMoney}]用来支付订单额[${orderTotal}]`); isPaySuccess = await finalPay(w1.channel, orderNum, orderTotal, orderInfo); break; } } } if (!isMateWallet) { lk.log('无匹配的钱包,请检查钱包余额'); } else if (isPaySuccess) { lk.log('支付成功'); } return isPaySuccess; } } else { lk.log(`订单[${orderNum}]已超时`); } } else { lk.log(`获取订单相关时间信息,发生异常`); } return false; } async function getOrderEndTime(orderNum) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = `orderNum=${orderNum}`; let url = { url: `${config.RESALE_API}/resaleManage/resale/getOrderEndTime`, headers: headers, body: body }; lk.log(`请求订单[${orderNum}]支付截止时间`); lk.post(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`获取订单支付截止时间发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`获取订单支付截止时间成功,响应:${data}`); ret = info.obj; } else { lk.log(`获取订单支付截止时间失败,响应:${data}`); } } } catch (e) { lk.log(`获取订单支付截止时间发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`获取订单支付截止时间发生错误`); lk.logErr(e); resolve(); } }); } async function transactionWalletList(orderNum) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = `orderNum=${orderNum}`; let url = { url: `${config.RESALE_API}/api/market/transactionWalletList`, headers: headers, body: body }; lk.log(`请求订单[${orderNum}]收款钱包列表`); lk.post(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求订单收款钱包列表发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`请求订单收款钱包列表成功`); if (info.obj) { ret = info.obj.walletList; } } else { lk.log(`请求订单[${orderNum}]收款钱包列表失败,响应:${data}`); } } } catch (e) { lk.log(`请求订单收款钱包列表发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求订单收款钱包列表发生错误`); lk.logErr(e); resolve(); } }); } async function getMyWalletListDetail() { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = ``; let url = { url: `${config.WALLET_API}/v2/wallet/list?`, headers: headers, body: body }; lk.log(`请求个人钱包列表数据`); lk.get(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求个人钱包列表数据发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { ret = info.obj; } else { lk.log(`请求个人钱包列表数据失败,响应:${data}`); } } } catch (e) { lk.log(`请求个人钱包列表数据发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求个人钱包列表数据发生错误`); lk.logErr(e); resolve(); } }); } async function verifyMyWalletPassword() { let publicKey = await getPublicKey(); if (publicKey) { let accountPassword = encryptPassword(publicKey, gandartPasswordPlaintext); let isOk = await confirmPassword(accountPassword); if (isOk) { return true; } return false; } return false; } function encryptPassword(publicKey, password) { let JSEncrypt = createJSEncrypt(); let crypt = new JSEncrypt(); crypt.setPublicKey(publicKey); let md5 = createWMd5(); return crypt.encrypt(md5.hex_md5_32Upper(password)); } async function getPublicKey() { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = ``; let url = { url: `${config.BASE_API}/reg/getPublicKey`, headers: headers, body: body }; lk.log(`请求支付密码相关的PublicKey`); lk.post(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求PublicKey发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`请求PublicKey成功`); ret = info.obj; } else { lk.log(`请求PublicKey失败`); } } } catch (e) { lk.log(`请求PublicKey发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求PublicKey发生错误`); lk.logErr(e); resolve(); } }); } async function confirmPassword(accountPassword) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = `accountPassword=${encodeURIComponent(accountPassword)}`; let url = { url: `${config.BASE_API}/user/confirmPassword`, headers: headers, body: body }; lk.log(`请求验证支付密码`); lk.post(url, async (error, _response, data) => { let ret = false; try { if (error) { lk.log(`请求验证支付密码发生错误`); lk.execFail(); } else { let info = JSON.parse(data); if (info.success) { lk.log(`请求验证支付密码通过`); ret = true; } else { lk.log(`请求验证支付密码失败,响应:${data}`); } } } catch (e) { lk.log(`请求验证支付密码发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求验证支付密码发生错误`); lk.logErr(e); resolve(); } }); } async function finalPay(walletName, orderNum, orderTotal, orderInfo) { let isSuccess = false; let isPass = false; switch (walletName) { case 'A': // 恒信通 isPass = await verifyMyWalletPassword(walletName, orderNum, orderTotal); if (isPass) { isSuccess = await hxtPay(orderNum, orderInfo); } break; case 'B': // 杉德 isSuccess = await sandPay(orderNum, orderInfo); break; case 'C': // 快付通 isPass = await verifyMyWalletPassword(walletName, orderNum, orderTotal); if (isPass) { isSuccess = await kftPay(orderNum, orderInfo); } break; default: break; } return isSuccess; } async function hxtPay(orderNum, orderInfo) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = `orderNum=${orderNum}&castingId=${orderInfo.castingId}&transactionRecordId=${orderInfo.transactionRecordId}&userId=${orderInfo.userId}`; let path = `${config.BASE_API}/v2/resaleManage/resale/pay`; let url = { url: path, headers: headers, body: body }; lk.log(`请求支付订单[${orderNum}]=${body}`); lk.post(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.execFail(); lk.appendNotifyInfo(`❌支付失败,请稍后再试`); } else { let info = JSON.parse(data); if (info.success) { ret = orderNum; lk.appendNotifyInfo(`🎉支付订单[${orderNum}]成功`); } else { lk.log(`请求支付订单[${orderNum}]失败,响应:${data}`); } } } catch (e) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.logErr(e); resolve(); } }); } async function sandPay(orderNum, orderInfo) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = `orderNum=${orderNum}&castingId=${orderInfo.castingId}&transactionRecordId=${orderInfo.transactionRecordId}&userId=${orderInfo.userId}`; let frontUrl = 'https://www.gandart.com/#/pagesB/detail/successfulSecondaryPayment'; body += `&frontUrl=${encodeURIComponent(frontUrl)}`; let path = `${config.BASE_API}/v2/resaleManage/resale/pay`; let url = { url: path, headers: headers, body: body }; lk.log(`请求支付订单[${orderNum}]=${body}`); lk.post(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.execFail(); lk.appendNotifyInfo(`❌支付失败,请稍后再试`); } else { let info = JSON.parse(data); if (info.success) { ret = orderNum; lk.appendNotifyInfo(`🎉支付订单[${orderNum}]受理成功`); // lk.appendNotifyInfo(`🎉打开链接支付[${info.passwordURL}]`); lk.msg('待支付通知', '点击跳转到浏览器打开', info.passwordURL, info.passwordURL); lk.pushWxMsg('光予支付手', `🎉支付订单[${orderNum}]受理成功,请打开链接支付[${info.passwordURL}]`, info.passwordURL); } else { lk.log(`请求支付订单[${orderNum}]失败,响应:${data}`); } } } catch (e) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.logErr(e); resolve(); } }); } async function kftPay(orderNum, orderInfo) { return new Promise((resolve, _reject) => { try { const headers = GCommonGandartHeads; headers.Host = "api.gandart.com"; const body = `orderNum=${orderNum}&castingId=${orderInfo.castingId}&transactionRecordId=${orderInfo.transactionRecordId}&userId=${orderInfo.userId}`; let path = `${config.WALLET_API}/v2/wallet/kft/pay`; let url = { url: path, headers: headers, body: body }; lk.log(`请求支付订单[${orderNum}]=${body}`); lk.post(url, async (error, _response, data) => { let ret; try { if (error) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.execFail(); lk.appendNotifyInfo(`❌支付失败,请稍后再试`); } else { let info = JSON.parse(data); if (info.success) { ret = orderNum; lk.appendNotifyInfo(`🎉支付订单[${orderNum}]成功`); } else { lk.log(`请求支付订单[${orderNum}]失败,响应:${data}`); } } } catch (e) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.logErr(e); lk.execFail(); } finally { resolve(ret); } }); } catch (e) { lk.log(`请求支付订单[${orderNum}]发生错误`); lk.logErr(e); resolve(); } }); } //---SyncByPyScript---ToolKit-start function ToolKit(t,s,e){return new class{constructor(t,s,e){this.tgEscapeCharMapping={"&":"&","#":"#"},this.userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.2 Safari/605.1.15",this.prefix="lk",this.name=t,this.id=s,this.data=null,this.dataFile=this.getRealPath(""+this.prefix+this.id+".dat"),this.boxJsJsonFile=this.getRealPath(""+this.prefix+this.id+".boxjs.json"),this.options=e,this.isExecComm=!1,this.isEnableLog=this.getVal(this.prefix+"IsEnableLog"+this.id),this.isEnableLog=!!this.isEmpty(this.isEnableLog)||JSON.parse(this.isEnableLog),this.isNotifyOnlyFail=this.getVal(this.prefix+"NotifyOnlyFail"+this.id),this.isNotifyOnlyFail=!this.isEmpty(this.isNotifyOnlyFail)&&JSON.parse(this.isNotifyOnlyFail),this.isEnableTgNotify=this.getVal(this.prefix+"IsEnableTgNotify"+this.id),this.isEnableTgNotify=!this.isEmpty(this.isEnableTgNotify)&&JSON.parse(this.isEnableTgNotify),this.tgNotifyUrl=this.getVal(this.prefix+"TgNotifyUrl"+this.id),this.isEnableTgNotify=this.isEnableTgNotify&&!this.isEmpty(this.tgNotifyUrl),this.costTotalStringKey=this.prefix+"CostTotalString"+this.id,this.costTotalString=this.getVal(this.costTotalStringKey),this.costTotalString=this.isEmpty(this.costTotalString)?"0,0":this.costTotalString.replace('"',""),this.costTotalMs=this.costTotalString.split(",")[0],this.execCount=this.costTotalString.split(",")[1],this.costTotalMs=this.isEmpty(this.costTotalMs)?0:parseInt(this.costTotalMs),this.execCount=this.isEmpty(this.execCount)?0:parseInt(this.execCount),this.logSeparator="\n██",this.now=new Date,this.startTime=this.now.getTime(),this.node=this.isNode()?{request:require("request")}:null,this.execStatus=!0,this.notifyInfo=[],this.log(this.name+", 开始执行!"),this.initCache(),this.checkRecordRequestBody(),this.execComm()}checkRecordRequestBody(){if(this.isRequest()){var s=$request.body;if(s){var e=$request.path;let t=this.id+"#"+e.replace("/","_");t=t.replace("?","#"),this.isQuanX()&&$prefs.setValueForKey(s,t),(this.isLoon()||this.isSurge())&&$persistentStore.write(s,t),this.isNode()&&this.node.fs.writeFileSync(t+".json",s,{flag:"w"},t=>console.log(t))}}}getRequestBody(){var t=$request.path;let s=this.id+"#"+t.replace("/","_");if(s=s.replace("?","#"),this.isSurge()||this.isLoon())return $persistentStore.read(s);if(this.isQuanX())return $prefs.valueForKey(s);if(this.isNode()){t=s+".json";if(!this.node.fs.existsSync(t))return JSON.parse(this.node.fs.readFileSync(t))}}initCache(){var t,s=this.getPersistKey();this.isQuanX()&&(this.cache=JSON.parse($prefs.valueForKey(s)||"{}")),(this.isLoon()||this.isSurge())&&(this.cache=JSON.parse($persistentStore.read(s)||"{}")),this.isNode()&&(this.node.fs.existsSync(t="root.json")||this.node.fs.writeFileSync(t,JSON.stringify({}),{flag:"wx"},t=>console.log(t)),this.root={},this.node.fs.existsSync(t=s+".json")?this.cache=JSON.parse(this.node.fs.readFileSync(s+".json")):(this.node.fs.writeFileSync(t,JSON.stringify({}),{flag:"wx"},t=>console.log(t)),this.cache={}))}getPersistKey(){return this.id+"#privateCache"}persistCache(){var t=this.getPersistKey(),s=JSON.stringify(this.cache,null,2);this.isQuanX()&&$prefs.setValueForKey(s,t),(this.isLoon()||this.isSurge())&&$persistentStore.write(s,t),this.isNode()&&(this.node.fs.writeFileSync(t+".json",s,{flag:"w"},t=>console.log(t)),this.node.fs.writeFileSync("root.json",JSON.stringify(this.root,null,2),{flag:"w"},t=>console.log(t)))}write(t,s){if(this.log("SET "+s),-1!==s.indexOf("#")){if(s=s.substr(1),isSurge||this.isLoon())return $persistentStore.write(t,s);if(this.isQuanX())return $prefs.setValueForKey(t,s);this.isNode()&&(this.root[s]=t)}else this.cache[s]=t;this.persistCache()}read(t){return this.log("READ "+t),-1!==t.indexOf("#")?(t=t.substr(1),this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?this.root[t]:void 0):this.cache[t]}delete(t){if(this.log("DELETE "+t),-1!==t.indexOf("#")){if(t=t.substr(1),this.isSurge()||this.isLoon())return $persistentStore.write(null,t);if(this.isQuanX())return $prefs.removeValueForKey(t);this.isNode()&&delete this.root[t]}else delete this.cache[t];this.persistCache()}getRealPath(t){var s;return this.isNode()?((s=process.argv.slice(1,2)[0].split("/"))[s.length-1]=t,s.join("/")):t}getUrlHost(t){return t.slice(0,t.indexOf("/",8))}getUrlPath(t){var s=t.lastIndexOf("/")===t.length-1?-1:void 0;return t.slice(t.indexOf("/",8),s)}async execComm(){if(this.isNode()){this.comm=process.argv.slice(1);let t=!1;"p"==this.comm[1]&&(this.isExecComm=!0,this.log(`开始执行指令【${this.comm[1]}】=> 发送到手机测试脚本!`),this.isEmpty(this.options)||this.isEmpty(this.options.httpApi)?(this.log("未设置options,使用默认值"),this.isEmpty(this.options)&&(this.options={}),this.options.httpApi="ffff@10.0.0.9:6166"):/.*?@.*?:[0-9]+/.test(this.options.httpApi)||(t=!0,this.log("❌httpApi格式错误!格式:ffff@3.3.3.18:6166"),this.done()),t||this.callApi(this.comm[2]))}}callApi(t){let i=this.comm[0],s=(this.log(`获取【${i}】内容传给手机`),"");this.fs=this.fs||require("fs"),this.path=this.path||require("path");var e=this.path.resolve(i),r=this.path.resolve(process.cwd(),i),o=this.fs.existsSync(e),h=!o&&this.fs.existsSync(r);if(o||h){h=o?e:r;try{s=this.fs.readFileSync(h)}catch(t){s=""}}else s="";o={url:`http://${this.options.httpApi.split("@")[1]}/v1/scripting/evaluate`,headers:{"X-Key":""+this.options.httpApi.split("@")[0]},body:{script_text:""+s,mock_type:"cron",timeout:!this.isEmpty(t)&&5{this.log(`已将脚本【${i}】发给手机!`),this.done()})}getCallerFileNameAndLine(){let s;try{throw Error("")}catch(t){s=t}var t=s.stack.split("\n")[1];return this.path=this.path||require("path"),`[${t.substring(t.lastIndexOf(this.path.sep)+1,t.lastIndexOf(":"))}]`}getFunName(t){t=t.toString();return t=(t=t.substr("function ".length)).substr(0,t.indexOf("("))}boxJsJsonBuilder(s,r){if(this.isNode()){let i="/Users/lowking/Desktop/Scripts/lowking.boxjs.json";if(r&&r.hasOwnProperty("target_boxjs_json_path")&&(i=r.target_boxjs_json_path),this.fs.existsSync(i))if(this.isJsonObject(s)&&this.isJsonObject(r)){this.log("using node");var o=["settings","keys"],h="https://raw.githubusercontent.com/Orz-3";let e={},t="#lk{script_url}";if(r&&r.hasOwnProperty("script_url")&&(t=this.isEmpty(r.script_url)?"#lk{script_url}":r.script_url),e.id=""+this.prefix+this.id,e.name=this.name,e.desc_html=`⚠️使用说明
详情【点我查看】`,e.icons=[h+`/mini/master/Alpha/${this.id.toLocaleLowerCase()}.png`,h+`/mini/master/Color/${this.id.toLocaleLowerCase()}.png`],e.keys=[],e.settings=[{id:this.prefix+"IsEnableLog"+this.id,name:"开启/关闭日志",val:!0,type:"boolean",desc:"默认开启"},{id:this.prefix+"NotifyOnlyFail"+this.id,name:"只当执行失败才通知",val:!1,type:"boolean",desc:"默认关闭"},{id:this.prefix+"IsEnableTgNotify"+this.id,name:"开启/关闭Telegram通知",val:!1,type:"boolean",desc:"默认关闭"},{id:this.prefix+"TgNotifyUrl"+this.id,name:"Telegram通知地址",val:"",type:"text",desc:"Tg的通知地址,如:https://api.telegram.org/bot-token/sendMessage?chat_id=-100140&parse_mode=Markdown&text="}],e.author="#lk{author}",e.repo="#lk{repo}",e.script=t+"?raw=true",!this.isEmpty(s))for(var n in o){var a=o[n];if(!this.isEmpty(s[a])){if("settings"===a)for(let t=0;tt.id==e.id)[0]);0<=c?u.apps[c]=e:u.apps.push(e);let s=JSON.stringify(u,null,2);if(!this.isEmpty(r))for(const m in r){let t="";r.hasOwnProperty(m)?t=r[m]:"author"===m?t="@lowking":"repo"===m&&(t="https://github.com/lowking/Scripts"),s=s.replace(`#lk{${m}}`,t)}for(var g,y=/(?:#lk\{)(.+?)(?=\})/,S=(null!==y.exec(s)&&this.log("生成BoxJs还有未配置的参数,请参考https://github.com/lowking/Scripts/blob/master/util/example/ToolKitDemo.js#L17-L18传入参数:\n"),new Set);null!==(g=y.exec(s));)S.add(g[1]),s=s.replace(`#lk{${g[1]}}`,"");S.forEach(t=>{console.log(t+" ")}),this.fs.writeFileSync(i,s)}}}else this.log("构建BoxJsJson传入参数格式错误,请传入json对象")}}isJsonObject(t){return"object"==typeof t&&"[object object]"==Object.prototype.toString.call(t).toLowerCase()&&!t.length}appendNotifyInfo(t,s){1==s?this.notifyInfo=t:this.notifyInfo.push(t)}prependNotifyInfo(t){this.notifyInfo.splice(0,0,t)}execFail(){this.execStatus=!1}isRequest(){return"undefined"!=typeof $request}isSurge(){return"undefined"!=typeof $httpClient}isQuanX(){return"undefined"!=typeof $task}isLoon(){return"undefined"!=typeof $loon}isJSBox(){return"undefined"!=typeof $app&&"undefined"!=typeof $http}isStash(){return"undefined"!=typeof $environment&&$environment["stash-version"]}isNode(){return"function"==typeof require&&!this.isJSBox()}async sleep(s){return new Promise(t=>setTimeout(t,s))}async wait(s){return new Promise(t=>setTimeout(t,s))}async delay(s){return new Promise(t=>setTimeout(t,s))}log(t){this.isEnableLog&&console.log(""+this.logSeparator+t)}logErr(t){this.execStatus=!0,this.isEnableLog&&(console.log(""+this.logSeparator+this.name+"执行异常:"),console.log(t),console.log("\n"+t.message))}msg(t,s,e,i){if((this.isRequest()||!this.isNotifyOnlyFail||!this.execStatus)&&(this.isEmpty(s)&&(s=Array.isArray(this.notifyInfo)?this.notifyInfo.join("\n"):this.notifyInfo),!this.isEmpty(s)))if(this.isEnableTgNotify){for(var r in this.log(this.name+"Tg通知开始"),this.tgEscapeCharMapping)this.tgEscapeCharMapping.hasOwnProperty(r)&&(s=s.replace(r,this.tgEscapeCharMapping[r]));this.get({url:encodeURI(this.tgNotifyUrl+"📌"+this.name+"\n"+s)},(t,s,e)=>{this.log("Tg通知完毕")})}else{var o={},h=!this.isEmpty(e),n=!this.isEmpty(i);this.isQuanX()&&(h&&(o["open-url"]=e),n&&(o["media-url"]=i),$notify(this.name,t,s,o)),(this.isSurge()||this.isStash())&&(h&&(o.url=e),$notification.post(this.name,t,s,o)),this.isNode()&&this.log("⭐️"+this.name+"\n"+t+"\n"+s),this.isJSBox()&&$push.schedule({title:this.name,body:t?t+"\n"+s:s})}}pushWxMsg(t,s,e,i=()=>{}){s={appToken:"AT_rTc93GQYIdMU8XLRnoJaSea8WkfhSzhX",content:s,summary:t,contentType:1,topicIds:[],uids:["UID_6P4B00X6Zv8U2oKC0I2R09emxtqq"],url:"",verifyPay:!1},e&&(s.url=e),t=this.getJsonDoneHeaders(),t.Host="wxpusher.zjiecode.com",t["Content-Type"]="application/json;charset=UTF-8",e={url:"https://wxpusher.zjiecode.com/api/send/message",headers:t,body:JSON.stringify(s)};this.post(e,i)}getVal(t,s=""){let e;return(e=this.isSurge()||this.isLoon()||this.isStash()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loadData(),process.env[t]||this.data[t]):this.data&&this.data[t]||null)||s}setVal(t,s){return this.isSurge()||this.isLoon()||this.isStash()?$persistentStore.write(s,t):this.isQuanX()?$prefs.setValueForKey(s,t):this.isNode()?(this.data=this.loadData(),this.data[t]=s,this.writeData(),!0):this.data&&this.data[t]||null}loadData(){if(!this.isNode())return{};this.fs=this.fs||require("fs"),this.path=this.path||require("path");var t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s);if(!e&&!i)return{};i=e?t:s;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}writeData(){var t,s,e,i,r;this.isNode()&&(this.fs=this.fs||require("fs"),this.path=this.path||require("path"),t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),i=!(e=this.fs.existsSync(t))&&this.fs.existsSync(s),r=JSON.stringify(this.data),!e&&i?this.fs.writeFileSync(s,r):this.fs.writeFileSync(t,r))}adapterStatus(t){return t&&(t.status?t.statusCode=t.status:t.statusCode&&(t.status=t.statusCode)),t}get(t,i=()=>{}){this.isQuanX()&&((t="string"==typeof t?{url:t}:t).method="GET",$task.fetch(t).then(t=>{i(null,this.adapterStatus(t),t.body)},t=>i(t.error,null,null))),(this.isSurge()||this.isLoon()||this.isStash())&&$httpClient.get(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)}),this.isNode()&&this.node.request(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)}),this.isJSBox()&&((t="string"==typeof t?{url:t}:t).header=t.headers,t.handler=function(t){let s=t.error,e=(s=s&&JSON.stringify(t.error),t.data);"object"==typeof e&&(e=JSON.stringify(t.data)),i(s,this.adapterStatus(t.response),e)},$http.get(t))}post(t,i=()=>{}){this.isQuanX()&&((t="string"==typeof t?{url:t}:t).method="POST",$task.fetch(t).then(t=>{i(null,this.adapterStatus(t),t.body)},t=>i(t.error,null,null))),(this.isSurge()||this.isLoon()||this.isStash())&&$httpClient.post(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)}),this.isNode()&&this.node.request.post(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)}),this.isJSBox()&&((t="string"==typeof t?{url:t}:t).header=t.headers,t.handler=function(t){let s=t.error,e=(s=s&&JSON.stringify(t.error),t.data);"object"==typeof e&&(e=JSON.stringify(t.data)),i(s,this.adapterStatus(t.response),e)},$http.post(t))}put(t,i=()=>{}){this.isQuanX()&&((t="string"==typeof t?{url:t}:t).method="PUT",$task.fetch(t).then(t=>{i(null,this.adapterStatus(t),t.body)},t=>i(t.error,null,null))),(this.isSurge()||this.isLoon()||this.isStash())&&(t.method="PUT",$httpClient.put(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)})),this.isNode()&&(t.method="PUT",this.node.request.put(t,(t,s,e)=>{i(t,this.adapterStatus(s),e)})),this.isJSBox()&&((t="string"==typeof t?{url:t}:t).header=t.headers,t.handler=function(t){let s=t.error,e=(s=s&&JSON.stringify(t.error),t.data);"object"==typeof e&&(e=JSON.stringify(t.data)),i(s,this.adapterStatus(t.response),e)},$http.post(t))}costTime(){let t=this.name+"执行完毕!";this.isNode()&&this.isExecComm&&(t=`指令【${this.comm[1]}】执行完毕!`);var s=(new Date).getTime()-this.startTime,e=s/1e3;this.execCount++,this.costTotalMs+=s,this.log(`${t}耗时【${e}】秒\n总共执行【${this.execCount}】次,平均耗时【${(this.costTotalMs/this.execCount/1e3).toFixed(4)}】秒`),this.setVal(this.costTotalStringKey,JSON.stringify(this.costTotalMs+","+this.execCount))}done(t={}){this.costTime(),(this.isSurge()||this.isQuanX()||this.isLoon()||this.isStash())&&$done(t)}getRequestUrl(){return $request.url}getResponseBody(){if($response)return $response.body}isGetCookie(t){return!("OPTIONS"==$request.method||!this.getRequestUrl().match(t))}isEmpty(t){return void 0===t||null==t||""==t||"null"==t||"undefined"==t||0===t.length}randomString(s){s=s||32;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890",i=e.length,r="";for(let t=0;t{var s,t=t.trim();let e=null,i=!0;if(t.includes("=")?(s=t.split("="),e=s[0].trim(),i=s[1].trim()):e=t,r.includes(e))h[o]&&(h[o][e]=i,h[o].attribs[e]=i);else{o=e;let s={};o.includes(",")&&o.split(",").forEach(t=>{t=t.trim();r.includes(t)?s[t]=!0:o=t}),h[o]={name:o,value:i,attribs:s},n.push(h[o])}}),n}base64Encode(t){var s,e,i,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let o,h,n;for(n=t.length,h=0,o="";h>2))+r.charAt((3&s)<<4)+"==";break}if(e=t.charCodeAt(h++),h==n){o=(o=(o+=r.charAt(s>>2))+r.charAt((3&s)<<4|(240&e)>>4))+r.charAt((15&e)<<2)+"=";break}i=t.charCodeAt(h++),o=(o=(o=(o+=r.charAt(s>>2))+r.charAt((3&s)<<4|(240&e)>>4))+r.charAt((15&e)<<2|(192&i)>>6))+r.charAt(63&i)}return o}base64Decode(t){var s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";if(/([^\s]+[^0-9a-zA-Z\+\/\=]|[^0-9a-zA-Z\+\/\=]\s+)/.test(t))throw new Error("Invalid base64 input");var e,i,r,o,h,n,a=t.replace(/\s/g,"");let l="",p=0;for(;p>2,i=(3&h)<<6|(n=s.indexOf(a.charAt(p++))),l+=String.fromCharCode(r<<2|o>>4),64!==h&&(l+=String.fromCharCode(e)),64!==n&&(l+=String.fromCharCode(i));return l=this.utf8Decode(l)}utf8Decode(s){let t=[],e=0,i=0,r=0;for(s=s.replace(/\r\n/g,"\n");e>10&1023)),t.push(String.fromCharCode(56320|1023&i))):t.push(String.fromCharCode(i)),e+=r}return t.join("")}parseJwt(t){try{var s=t.split("."),e=s[0].replace(/-/g,"+").replace(/_/g,"/"),i=this.base64Decode(e).replace(/\0/g,""),r=JSON.parse(i),o=s[1].replace(/-/g,"+").replace(/_/g,"/"),h=this.base64Decode(o).replace(/\0/g,"");return{header:r,payload:JSON.parse(h),signature:s[2]}}catch(t){return this.log(t),null}}}(t,s,e)} //---SyncByPyScript---ToolKit-end //---SyncByPyScript---JSEncrypt-start function createJSEncrypt(){function a(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function L(t,e){return t&e}function h(t,e){return t|e}function j(t,e){return t^e}function H(t,e){return t&~e}var u,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function r(t){for(var e,i="",r=0;r+3<=t.length;r+=3)e=parseInt(t.substring(r,r+3),16),i+=o.charAt(e>>6)+o.charAt(63&e);for(r+1==t.length?(e=parseInt(t.substring(r,r+1),16),i+=o.charAt(e<<2)):r+2==t.length&&(e=parseInt(t.substring(r,r+2),16),i+=o.charAt(e>>2)+o.charAt((3&e)<<4));0<(3&i.length);)i+="=";return i}function C(t){for(var e="",i=0,r=0,n=0;n>2),r=3&s,1):1==i?(e+=a(r<<2|s>>4),r=15&s,2):2==i?(e=(e+=a(r))+a(s>>2),r=3&s,3):(e=(e+=a(r<<2|s>>4))+a(15&s),0))}return 1==i&&(e+=a(r<<2)),e}var c,F=function(t){if(void 0===u){var e="0123456789ABCDEF",i=" \f\n\r\t \u2028\u2029";for(u={},o=0;o<16;++o)u[e.charAt(o)]=o;for(e=e.toLowerCase(),o=10;o<16;++o)u[e.charAt(o)]=o;for(o=0;o>16,i[i.length]=r>>8&255,i[i.length]=255&r,n=r=0):r<<=6}}switch(n){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=r>>10;break;case 3:i[i.length]=r>>16,i[i.length]=r>>8&255}return i},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=U.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return U.decode(t)}},f=1e13,l=(t.prototype.mulAdd=function(t,e){for(var i,r=this.buf,n=r.length,s=0;se?t.substring(0,e)+"…":t}i.prototype.get=function(t){if((t=void 0===t?this.pos++:t)>=this.enc.length)throw new Error("Requesting byte offset ".concat(t," on a stream of length ").concat(this.enc.length));return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]},i.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},i.prototype.hexDump=function(t,e,i){for(var r="",n=t;n>u&1?"1":"0";if(s.length>i)return n+p(s,i)}return n+s},i.prototype.parseOctetString=function(t,e,i){if(this.isASCII(t,e))return p(this.parseStringISO(t,e),i);var r=e-t,n="("+r+" byte)\n";(i/=2)i)return p(r,i);n=new l,s=0}}return 0>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){for(var i=new l;e=t.get(),i.mulAdd(128,127&e),128&e;);this.tagNumber=i.simplify()}}var d=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],$=(1<<26)/d[d.length-1],m=(y.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<>h)&&(n=!0,s=a(i));0<=o;)h>(h+=this.DB-e)):(i=this[o]>>(h-=e)&r,h<=0&&(h+=this.DB,--o)),(n=0>24},y.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},y.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},y.prototype.toByteArray=function(){var t,e=this.t,i=[],r=(i[0]=this.s,this.DB-e*this.DB%8),n=0;if(0>r)!=(this.s&this.DM)>>r&&(i[n++]=t|this.s<>(r+=this.DB-8)):(t=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),0!=(128&t)&&(t|=-256),0==n&&(128&this.s)!=(128&t)&&++n,(0>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e));return this.s<0?this.t*this.DB:-1},y.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i=this.t?0!=this.s:0!=(this[e]&1<>i-a&u:(f=(t[p]&(1<>this.DB+i-a)),h=n;0==(1&f);)f>>=1,--h;if((i-=h)<0&&(i+=this.DB,--p),g)o[f].copyTo(r),g=!1;else{for(;1this.DB?(this[this.t-1]|=(o&(1<>this.DB-s):this[this.t-1]|=o<=this.DB&&(s-=this.DB))}8==i&&0!=(128&+t[0])&&(this.s=-1,0>r|o,o=(this[h]&n)<=this.t)e.t=0;else{var r=t%this.DB,n=this.DB-r,s=(1<>r;for(var o=i+1;o>r;0>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:0=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}0>this.F2:0),c=this.FV/r,f=(1<=i&&(this.dMultiply(r),this.dAddOffset(o,0),o=s=0))}0t&&this.subTo(y.ONE.shiftLeft(t-1),this);else{var i=[],r=7&t;i.length=1+(t>>3),e.nextBytes(i),0>=this.DB;if(t.t>=this.DB;r+=this.s}else{for(r+=this.s;i>=this.DB;r+=t.s}e.s=r<0?-1:0,0=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},y.prototype.multiplyLowerTo=function(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;0>1)&&(t=d.length),b()),s=0;st&&n.subTo(y.ONE.shiftLeft(t-1),n),n.isProbablePrime(e)?setTimeout(function(){r()},0):setTimeout(s,0)},setTimeout(s,0)):(i=7&t,(o=[]).length=1+(t>>3),e.nextBytes(o),0>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),0<=t.compareTo(this.m)&&t.subTo(this.m,t)},s.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},s.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var X=s;function s(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<2*this.m.t?t.mod(this.m):t.compareTo(this.m)<0?t:(e=b(),t.copyTo(e),this.reduce(e),e)},v.prototype.revert=function(t){return t},v.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);0<=t.compareTo(this.m);)t.subTo(this.m,t)},v.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},v.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var Q=v;function v(t){this.m=t,this.r2=b(),this.q3=b(),m.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}function b(){return new m(null)}function T(t,e){return new m(t,e)}for(var S="undefined"!=typeof navigator,S=S&&"Microsoft Internet Explorer"==navigator.appName?(m.prototype.am=function(t,e,i,r,n,s){for(var o=32767&e,h=e>>15;0<=--s;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;n=((a=o*a+((32767&c)<<15)+i[r]+(1073741823&n))>>>30)+(c>>>15)+h*u+(n>>>30),i[r++]=1073741823&a}return n},30):S&&"Netscape"!=navigator.appName?(m.prototype.am=function(t,e,i,r,n,s){for(;0<=--s;){var o=e*this[t++]+i[r]+n;n=Math.floor(o/67108864),i[r++]=67108863&o}return n},26):(m.prototype.am=function(t,e,i,r,n,s){for(var o=16383&e,h=e>>14;0<=--s;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;n=((a=o*a+((16383&c)<<14)+i[r]+n)>>28)+(c>>14)+h*u,i[r++]=268435455&a}return n},28),E=(m.prototype.DB=S,m.prototype.DM=(1<>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}m.ZERO=x(0),m.ONE=x(1);et.prototype.init=function(t){for(var e,i,r=0;r<256;++r)this.S[r]=r;for(r=e=0;r<256;++r)e=e+this.S[r]+t[r%t.length]&255,i=this.S[r],this.S[r]=this.S[e],this.S[e]=i;this.i=0,this.j=0},et.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var tt=et;function et(){this.i=0,this.j=0,this.S=[]}var it,B,A,rt,nt,O,V=null;if(null==V){if(V=[],A=void(B=0),"undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues)for(rt=new Uint32Array(256),window.crypto.getRandomValues(rt),A=0;A>3,t=function(t,e){if(e>6|192):(i[--e]=63&n|128,i[--e]=n>>6&63|128,i[--e]=n>>12|224)}i[--e]=0;for(var s=new ot,o=[];2>1,n=(this.e=parseInt(e,16),new m(e,16));;){for(;this.p=new m(t-r,1,i),0!=this.p.subtract(m.ONE).gcd(n).compareTo(m.ONE)||!this.p.isProbablePrime(10););for(;this.q=new m(r,1,i),0!=this.q.subtract(m.ONE).gcd(n).compareTo(m.ONE)||!this.q.isProbablePrime(10););this.p.compareTo(this.q)<=0&&(s=this.p,this.p=this.q,this.q=s);var s=this.p.subtract(m.ONE),o=this.q.subtract(m.ONE),h=s.multiply(o);if(0==h.gcd(n).compareTo(m.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(h),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(o),this.coeff=this.q.modInverse(this.p);break}}},I.prototype.decrypt=function(t){t=T(t,16),t=this.doPrivate(t);if(null==t)return null;for(var e=this.n.bitLength()+7>>3,i=t.toByteArray(),r=0;r=i.length)return null;for(var n="";++r>1,h=(this.e=parseInt(e,16),new m(e,16)),a=this,u=function(){function e(){a.p=b(),a.p.fromNumberAsync(t-o,1,s,function(){a.p.subtract(m.ONE).gcda(h,function(t){0==t.compareTo(m.ONE)&&a.p.isProbablePrime(10)?setTimeout(r,0):setTimeout(e,0)})})}var i=function(){a.p.compareTo(a.q)<=0&&(t=a.p,a.p=a.q,a.q=t);var t=a.p.subtract(m.ONE),e=a.q.subtract(m.ONE),i=t.multiply(e);0==i.gcd(h).compareTo(m.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(i),a.dmp1=a.d.mod(t),a.dmq1=a.d.mod(e),a.coeff=a.q.modInverse(a.p),setTimeout(function(){n()},0)):setTimeout(u,0)},r=function(){a.q=b(),a.q.fromNumberAsync(o,1,s,function(){a.q.subtract(m.ONE).gcda(h,function(t){0==t.compareTo(m.ONE)&&a.q.isProbablePrime(10)?setTimeout(i,0):setTimeout(r,0)})})};setTimeout(e,0)};setTimeout(u,0)},I.prototype.sign=function(t,e,i){i=function(t,e){if(e=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,i,r,n,s){t=new Date(Date.UTC(t,e-1,i,r,n,s,0));this.setByDate(t)},this.getFreshValueHex=function(){return this.hV}},N.lang.extend(P.asn1.DERAbstractTime,P.asn1.ASN1Object),P.asn1.DERAbstractStructured=function(t){P.asn1.DERAbstractString.superclass.constructor.call(this);this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},N.lang.extend(P.asn1.DERAbstractStructured,P.asn1.ASN1Object),P.asn1.DERBoolean=function(){P.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},N.lang.extend(P.asn1.DERBoolean,P.asn1.ASN1Object),P.asn1.DERInteger=function(t){P.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=P.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){t=new m(String(t),10);this.setByBigInteger(t)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},N.lang.extend(P.asn1.DERInteger,P.asn1.ASN1Object),P.asn1.DERBitString=function(t){var e;void 0!==t&&void 0!==t.obj&&(e=P.asn1.ASN1Util.newObject(t.obj),t.hex="00"+e.getEncodedHex()),P.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7>>32-n}function i(r,n){var t=2147483648&r,e=2147483648&n,o=1073741824&r,u=1073741824&n,r=(1073741823&r)+(1073741823&n);return o&u?2147483648^r^t^e:o|u?1073741824&r?3221225472^r^t^e:1073741824^r^t^e:r^t^e}function t(r,n,t,e,o,u,f){return r=i(r,i(i(n&t|~n&e,o),f)),i(a(r,u),n)}function e(r,n,t,e,o,u,f){return r=i(r,i(i(n&e|t&~e,o),f)),i(a(r,u),n)}function o(r,n,t,e,o,u,f){return r=i(r,i(i(n^t^e,o),f)),i(a(r,u),n)}function u(r,n,t,e,o,u,f){return r=i(r,i(i(t^(n|~e),o),f)),i(a(r,u),n)}function f(r){for(var n="",t="",e=0;e<=3;e++)n+=(t="0"+(r>>>8*e&255).toString(16)).substr(t.length-2,2);return n}Array();for(var h,c,d,C,m=function(r){for(var n,t=r.length,e=16*(1+((e=t+8)-e%64)/64),o=Array(e-1),u=0,f=0;f>>29,o}(r=function(r){r=r.replace(/\r\n/g,"\n");for(var n="",t=0;t>6|192))+String.fromCharCode(63&e|128):(n=(n+=String.fromCharCode(e>>12|224))+String.fromCharCode(e>>6&63|128))+String.fromCharCode(63&e|128)}return n}(r)),_=1732584193,g=4023233417,p=2562383102,x=271733878,v=0;v