/* WPS_PC签到 仅测试Quantumult-X,nodejs,其他自测 2024-10-16 先这样写着能用,后期看情况再改 2024-10-22 修改签到样式 将领取状态用数字1到7显示,空心①②③④⑤⑥⑦【未领取】,实心❶❷❸❹❺❻❼【已领取】 脚本参考 @小 白脸 https://t.me/NobyDa/896 https://raw.githubusercontent.com/githubdulong/Script/master/WPS_checkin.js 抓cookie(手机用qx,loon,surge等可以自动抓cookie,请自行配置) 用手机或者电脑进入https://vip.wps.cn/home登录后,找到cookie里面的wps_sid,格式如下 # 青龙环境变量 wps_pc_val = {"cookie":"wps_sid=xxxxxxxxxxxx"} ======调试区|忽略====== # ^https:\/\/(vip|account)(userinfo|\.wps\.cn\/p\/auth\/check)$ url script-request-header http://192.168.2.170:8080/wps.js ======调试区|忽略====== ==================================== [rewrite_local] ^https:\/\/(vip|account)(userinfo|\.wps\.cn\/p\/auth\/check)$ url script-request-header https://raw.githubusercontent.com/wf021325/qx/master/task/wps.js [task_local] 1 0 * * * https://raw.githubusercontent.com/wf021325/qx/master/task/wps.js, tag= WPS_PC签到, enabled=true [mitm] hostname = *.wps.cn ==================================== */ const $ = new Env("WPS_PC签到"); const _key = 'wps_pc_val'; const ckval = $.toObj(getEnv(_key)); $.is_debug ='true-' $.messages = []; async function pushMsg(msg) {$.messages.push(msg.trimEnd()), $.log(msg.trimEnd());} async function main() { intRSA(); const {result, msg, nickname} = await getUsername(); if(result=='ok'){ $.username = nickname; //pushMsg(`用户: ${nickname}`); await getBalance(); const t = await getsalt(); if (t) { await signIn(t); } }else { pushMsg(wps_msg(msg) ? wps_msg(msg) : result + '|' + msg); return; } } // 获取用户名 async function getUsername() { url = 'https://account.wps.cn/p/auth/check'; headers = getHeaders(); return await httpRequest({url, body: '', headers, method: 'POST'}); } // 获取余额 async function getBalance() { url = 'https://personal-act.wps.cn/wps_clock/v2/user'; headers = getHeaders(); const {result, data, msg} = await httpRequest({url, headers}); //pushMsg(`🏦已使用额度: ${data.cost / 3600}小时(${Math.floor(data.cost / 86400)})天`); //pushMsg(`💰剩余额度: ${data.total / 3600}小时(${Math.floor(data.total / 86400)})天`); $.使用情况 = `已用:${data.cost / 3600}小时(${Math.floor(data.cost / 86400)})天/剩余:${data.total / 3600}小时(${Math.floor(data.total / 86400)})天` //pushMsg(`已用:${data.cost / 3600}小时(${Math.floor(data.cost / 86400)})天/剩余:${data.total / 3600}小时(${Math.floor(data.total / 86400)})天`) } // 每天领取详情 和 签到使用的salt async function getsalt() { url = 'https://personal-act.wps.cn/wps_clock/v2'; headers = getHeaders(); const {result, data, msg} = await httpRequest({url, headers}); if (result === 'ok') { const {reward, todayReward, signStatus} = await formatRewardInfo(data) //pushMsg(reward.join('\n')) // 每行显示每天的领取情况 pushMsg(`${$.username}[${$.time('yyyy-MM-dd', data.start * 1000)} 至 ${$.time('yyyy-MM-dd', data.end * 1000)}]\n${$.使用情况}\n签到详情:${signStatus}`) } else ( pushMsg(wps_msg(msg) ? wps_msg(msg) : result + '|' + msg) ) return data.t } //签到 async function signIn(p) { url = 'https://personal-act.wps.cn/wps_clock/v2'; body = 'double=0&v=12.1.0.18276&p=' + encodeURIComponent(RSA_Public_Encrypt(getNonce() + ';' + p)) + '&version=12.1.0.18276'; headers = getHeaders(); const {result, data, msg} = await httpRequest({url, body, headers}); let _msg = '签到:'; _msg += result === 'ok' ? '签到成功' : result === 'UserNotLogin' ? `${result}|请重新获取cookie` : (wps_msg(msg) ? wps_msg(msg) : result + '|' + msg); pushMsg(_msg) } function getHeaders() { return { "accept": "application/json, text/plain, */*", "accept-language": "zh-CN,zh;q=0.9", "content-type": "application/x-www-form-urlencoded", "user-agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 WpsOfficeApp/12.1.0.18276 (per,windows)", "origin": "https://personal-act.wps.cn", "cookie": $.cookie } } //格式化奖励信息 async function formatRewardInfo(data) { let todayReward, signStatus = ''; const reward = data.list.map(({status, times, selected, ext}) => { // const {hour, name} = JSON.parse(ext)[0]; //selected && status && (todayReward = `获得${hour}小时会员`);//当天 signStatus += updateSignInStatus(times, status);// //return `⌚️第${times}天🎁奖励${hour}小时会员🎊${status ? "已领取" : "未领取"}`; }); return {reward, todayReward, signStatus}; } // 将领取状态用符号显示,空心【未领取】,实心为【已领取】 function updateSignInStatus(times, status) { const symbols = [['①', '❶'], ['②', '❷'], ['③', '❸'], ['④', '❹'], ['⑤', '❺'], ['⑥', '❻'], ['⑦', '❼'], ['⑧', '❽'], ['⑨', '❾'], ['⑩', '❿'], ['⑪', '⓫'], ['⑫', '⓬'], ['⑬', '⓭'], ['⑭', '⓮'], ['⑮', '⓯'], ['⑯', '⓰'], ['⑰', '⓱'], ['⑱', '⓲'], ['⑲', '⓳'], ['⑳', '⓴']]; let symbol = status ? symbols[times - 1][1] : symbols[times - 1][0]; return symbol; } // 部分报错信息 function wps_msg(msg) { const messages = { "userNotLogin": "灰灰提醒:请重新获取cookie", "ErrorEncryption": "灰灰提醒:如果突然出现这个提示,那就是wps更新了算法", "err param": "灰灰提醒:提交数据错误", "CACHE_EMPTY": "灰灰提醒:验证码位空,请勿骚操作", "ErrorHdid": "灰灰提醒:设备id错误", "captcha invalid": "验证异常,请重新选择", "points not match": "验证失败,请重新选择", "ClockAgent": "今天此设备已签到过了!", "ErrorHdidTodayDone": "今天此设备已签到过了!", "ClientNeedUpgrade": "当前客户端版本过低,无法完成操作,请更新至最新版" }; return messages[msg]; } async function getCookie() { if ($request && $request.method !== 'OPTIONS') { const head = ObjectKeys2LowerCase($request.headers); const ck = head['cookie']; const wps_sid = getCookieValue(ck, 'wps_sid'); if (wps_sid) { const ckVal = 'wps_sid=' + wps_sid; $.setdata($.toStr({cookie: ckVal}), _key); $.msg($.name, '获取ck成功🎉', ckVal); } else { $.msg($.name, '', '❌获取ck失败'); } } } !(async () => { if (typeof $request !== `undefined`) { await getCookie(); return; } if (!ckval) { sendMsg('❌请先获取cookie🎉') return; } $.cookie = ckval.cookie await main(); })().catch((e) => $.messages.push(e.message || e) && $.logErr(e)) .finally(async () => { await sendMsg($.messages.join('\n')); $.done(); }) // 随机字符 function getNonce(){return Array.from({length:32},(r,n)=>12===n?"4":"0123456789abcdef"[Math.floor(16*Math.random())]).join("")}; // 获取 cookie 指定 键值 function getCookieValue(cookie,key){const cookies=cookie.split('; ');for(let cookie of cookies){const[k,v]=cookie.split('=');if(k===key){return v;}}return null;} // headers 转小写 function ObjectKeys2LowerCase(obj){return Object.fromEntries(Object.entries(obj).map(([k,v])=>[k.toLowerCase(),v]))}; // 二次封装 async function httpRequest(options) { try { options = options.url ? options : { url: options }; const _method = options?._method || ('body' in options ? 'post' : 'get'); const _respType = options?._respType || 'body'; const _timeout = options?._timeout || 15e3; const _http = [ new Promise((_, reject) => setTimeout(() => reject(`⛔️ 请求超时: ${options['url']}`), _timeout)), new Promise((resolve, reject) => { //debug(options, '[Request]'); $[_method.toLowerCase()](options, (error, response, data) => { //debug(response, '[response]'); debug(data, '[data]'); error && $.log($.toStr(error)); if (_respType !== 'all') { resolve($.toObj(response?.[_respType], response?.[_respType])); } else { resolve(response); } }) }) ]; return await Promise.race(_http); } catch (err) { $.logErr(err); } } // debug function debug(content,title="debug"){let start=`┌---------------↓↓${title}↓↓---------------\n`;let end=`\n└---------------↑↑${$.time('HH:mm:ss')}↑↑---------------`;if($.is_debug==='true'){if(typeof content=="string"){$.log(start+content.replace(/\s+/g,'')+end);}else if(typeof content=="object"){$.log(start+$.toStr(content)+end);}}}; // 通知 async function sendMsg(message){if(!message)return;try{if($.isNode()){try{var notify=require('./sendNotify');}catch(e){var notify=require('./utils/sendNotify');}await notify.sendNotify($.name,message);}else{$.msg($.name,'',message);}}catch(e){$.log(`\n\n-----${$.name}-----\n${message}`);}}; // 读取环境变量 function getEnv(...keys) {for (let key of keys) {var value = $.isNode() ? process.env[key] || process.env[key.toUpperCase()] || process.env[key.toLowerCase()] || $.getdata(key) : $.getdata(key);if (value) return value;}}; //************RSA function intRSA(){RSA={};!function(exports){var window={},navigator={},dbits;Array.prototype.forEach||(Array.prototype.forEach=function(t,e){var i,r;if(null==this)throw new TypeError(" this is null or not defined");var n=Object(this),s=n.length>>>0;if("function"!=typeof t)throw new TypeError(t+" is not a function");for(arguments.length>1&&(i=e),r=0;r=0;){var o=e*this[t++]+i[r]+n;n=Math.floor(o/67108864),i[r++]=67108863&o}return n}function am2(t,e,i,r,n,s){for(var o=32767&e,h=e>>15;--s>=0;){var a=32767&this[t],u=this[t++]>>15,p=h*a+u*o;n=((a=o*a+((32767&p)<<15)+i[r]+(1073741823&n))>>>30)+(p>>>15)+h*u+(n>>>30),i[r++]=1073741823&a}return n}function am3(t,e,i,r,n,s){for(var o=16383&e,h=e>>14;--s>=0;){var a=16383&this[t],u=this[t++]>>14,p=h*a+u*o;n=((a=o*a+((16383&p)<<14)+i[r]+n)>>28)+(p>>14)+h*u,i[r++]=268435455&a}return n}j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function bnpFromInt(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0}function nbv(t){var e=nbi();return e.fromInt(t),e}function bnpFromString(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var r=t.length,n=!1,s=0;--r>=0;){var o=8==i?255&t[r]:intAt(t,r);o<0?"-"==t.charAt(r)&&(n=!0):(n=!1,0==s?this[this.t++]=o:s+i>this.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,s>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t}function bnToString(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<0)for(h>h)>0&&(n=!0,s=int2char(i));o>=0;)h>(h+=this.DB-e)):(i=this[o]>>(h-=e)&r,h<=0&&(h+=this.DB,--o)),i>0&&(n=!0),n&&(s+=int2char(i));return n?s:"0"}function bnNegate(){var t=nbi();return BigInteger.ZERO.subTo(this,t),t}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0}function nbits(t){var e,i=1;return 0!=(e=t>>>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}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s}function bnpDRShiftTo(t,e){for(var i=t;i=0;--i)e[i+o+1]=this[i]>>n|h,h=(this[i]&s)<=0;--i)e[i]=0;e[o]=h,e.t=this.t+o+1,e.s=this.s,e.clamp()}function bnpRShiftTo(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=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;r>0&&(e[this.t-i-1]|=(this.s&s)<>=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:r>0&&(e[i++]=r),e.t=i,e.clamp()}function bnpMultiplyTo(t,e){var i=this.abs(),r=t.abs(),n=i.t;for(e.t=n+r.t;--n>=0;)e[n]=0;for(n=0;n=0;)t[i]=0;for(i=0;i=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()}function bnpDivRemTo(t,e,i){var r=t.abs();if(!(r.t<=0)){var n=this.abs();if(n.t0?(r.lShiftTo(a,s),n.lShiftTo(a,i)):(r.copyTo(s),n.copyTo(i));var u=s.t,p=s[u-1];if(0!=p){var c=p*(1<1?s[u-2]>>this.F2:0),g=this.FV/c,l=(1<=0&&(i[i.t++]=1,i.subTo(v,i)),BigInteger.ONE.dlShiftTo(u,v),v.subTo(s,s);s.t=0;){var y=i[--d]==p?this.DM:Math.floor(i[d]*g+(i[d-1]+f)*l);if((i[d]+=s.am(0,y,i,b,0,u))0&&i.rShiftTo(a,i),o<0&&BigInteger.ZERO.subTo(i,i)}}}function bnMod(t){var e=nbi();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e}function Classic(t){this.m=t}function cConvert(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function cRevert(t){return t}function cReduce(t){t.divRemTo(this.m,null,t)}function cMulTo(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function cSqrTo(t,e){t.squareTo(e),this.reduce(e)}function bnpInvDigit(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e}function Montgomery(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(e,e),e}function montRevert(t){var e=nbi();return t.copyTo(e),this.reduce(e),e}function montReduce(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>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),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function montSqrTo(t,e){t.squareTo(e),this.reduce(e)}function montMulTo(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)}function bnpExp(t,e){if(t>4294967295||t<1)return BigInteger.ONE;var i=nbi(),r=nbi(),n=e.convert(this),s=nbits(t)-1;for(n.copyTo(i);--s>=0;)if(e.sqrTo(i,r),(t&1<0)e.mulTo(r,n,i);else{var o=i;i=r,r=o}return e.revert(i)}function bnModPowInt(t,e){var i;return i=t<256||e.isEven()?new Classic(e):new Montgomery(e),this.exp(t,i)}function bnClone(){var t=nbi();return this.copyTo(t),t}function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function bnpToRadix(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),r=nbv(i),n=nbi(),s=nbi(),o="";for(this.divRemTo(r,n,s);n.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,n.divRemTo(r,n,s);return s.intValue().toString(t)+o}function bnpFromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),r=Math.pow(e,i),n=!1,s=0,o=0,h=0;h=i&&(this.dMultiply(r),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),n&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var r=new Array,n=7&t;r.length=1+(t>>3),e.nextBytes(r),n>0?r[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<=0;)r<8?(i=(this[t]&(1<>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(n>0||i!=this.s)&&(e[n++]=i);return e}function bnEquals(t){return 0==this.compareTo(t)}function bnMin(t){return this.compareTo(t)<0?this:t}function bnMax(t){return this.compareTo(t)>0?this:t}function bnpBitwiseTo(t,e,i){var r,n,s=Math.min(t.t,this.t);for(r=0;r>=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}function bnGetLowestSetBit(){for(var t=0;t=this.t?0!=this.s:0!=(this[e]&1<>=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>0?e[i++]=r:r<-1&&(e[i++]=this.DV+r),e.t=i,e.clamp()}function bnAdd(t){var e=nbi();return this.addTo(t,e),e}function bnSubtract(t){var e=nbi();return this.subTo(t,e),e}function bnMultiply(t){var e=nbi();return this.multiplyTo(t,e),e}function bnSquare(){var t=nbi();return this.squareTo(t),t}function bnDivide(t){var e=nbi();return this.divRemTo(t,e,null),e}function bnRemainder(t){var e=nbi();return this.divRemTo(t,null,e),e}function bnDivideAndRemainder(t){var e=nbi(),i=nbi();return this.divRemTo(t,e,i),new Array(e,i)}function bnpDMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function NullExp(){}function nNop(t){return t}function nMulTo(t,e,i){t.multiplyTo(e,i)}function nSqrTo(t,e){t.squareTo(e)}function bnPow(t){return this.exp(t,new NullExp)}function bnpMultiplyLowerTo(t,e,i){var r,n=Math.min(this.t+t.t,e);for(i.s=0,i.t=n;n>0;)i[--n]=0;for(r=i.t-this.t;n=0;)i[r]=0;for(r=Math.max(e-this.t,0);r2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=nbi();return t.copyTo(e),this.reduce(e),e}function barrettRevert(t){return t}function barrettReduce(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);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function barrettSqrTo(t,e){t.squareTo(e),this.reduce(e)}function barrettMulTo(t,e,i){t.multiplyTo(e,i),this.reduce(i)}function bnModPow(t,e){var i,r,n=t.bitLength(),s=nbv(1);if(n<=0)return s;i=n<18?1:n<48?3:n<144?4:n<768?5:6,r=n<8?new Classic(e):e.isEven()?new Barrett(e):new Montgomery(e);var o=new Array,h=3,a=i-1,u=(1<1){var p=nbi();for(r.sqrTo(o[1],p);h<=u;)o[h]=nbi(),r.mulTo(p,o[h-2],o[h]),h+=2}var c,g,l=t.t-1,f=!0,d=nbi();for(n=nbits(t[l])-1;l>=0;){for(n>=a?c=t[l]>>n-a&u:(c=(t[l]&(1<0&&(c|=t[l-1]>>this.DB+n-a)),h=i;0==(1&c);)c>>=1,--h;if((n-=h)<0&&(n+=this.DB,--l),f)o[c].copyTo(s),f=!1;else{for(;h>1;)r.sqrTo(s,d),r.sqrTo(d,s),h-=2;h>0?r.sqrTo(s,d):(g=s,s=d,d=g),r.mulTo(d,o[c],s)}for(;l>=0&&0==(t[l]&1<0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i}function bnpModInt(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i}function bnModInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return BigInteger.ZERO;for(var i=t.clone(),r=this.clone(),n=nbv(1),s=nbv(0),o=nbv(0),h=nbv(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(t,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),e?(o.isEven()&&h.isEven()||(o.addTo(this,o),h.subTo(t,h)),o.rShiftTo(1,o)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);i.compareTo(r)>=0?(i.subTo(r,i),e&&n.subTo(o,n),s.subTo(h,s)):(r.subTo(i,r),e&&o.subTo(n,o),h.subTo(s,h))}return 0!=r.compareTo(BigInteger.ONE)?BigInteger.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h}Classic.prototype.convert=cConvert,Classic.prototype.revert=cRevert,Classic.prototype.reduce=cReduce,Classic.prototype.mulTo=cMulTo,Classic.prototype.sqrTo=cSqrTo,Montgomery.prototype.convert=montConvert,Montgomery.prototype.revert=montRevert,Montgomery.prototype.reduce=montReduce,Montgomery.prototype.mulTo=montMulTo,Montgomery.prototype.sqrTo=montSqrTo,BigInteger.prototype.copyTo=bnpCopyTo,BigInteger.prototype.fromInt=bnpFromInt,BigInteger.prototype.fromString=bnpFromString,BigInteger.prototype.clamp=bnpClamp,BigInteger.prototype.dlShiftTo=bnpDLShiftTo,BigInteger.prototype.drShiftTo=bnpDRShiftTo,BigInteger.prototype.lShiftTo=bnpLShiftTo,BigInteger.prototype.rShiftTo=bnpRShiftTo,BigInteger.prototype.subTo=bnpSubTo,BigInteger.prototype.multiplyTo=bnpMultiplyTo,BigInteger.prototype.squareTo=bnpSquareTo,BigInteger.prototype.divRemTo=bnpDivRemTo,BigInteger.prototype.invDigit=bnpInvDigit,BigInteger.prototype.isEven=bnpIsEven,BigInteger.prototype.exp=bnpExp,BigInteger.prototype.toString=bnToString,BigInteger.prototype.negate=bnNegate,BigInteger.prototype.abs=bnAbs,BigInteger.prototype.compareTo=bnCompareTo,BigInteger.prototype.bitLength=bnBitLength,BigInteger.prototype.mod=bnMod,BigInteger.prototype.modPowInt=bnModPowInt,BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=nMulTo,NullExp.prototype.sqrTo=nSqrTo,Barrett.prototype.convert=barrettConvert,Barrett.prototype.revert=barrettRevert,Barrett.prototype.reduce=barrettReduce,Barrett.prototype.mulTo=barrettMulTo,Barrett.prototype.sqrTo=barrettSqrTo;var lowprimes=[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],lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(t){var e,i=this.abs();if(1==i.t&&i[0]<=lowprimes[lowprimes.length-1]){for(e=0;e>1)>lowprimes.length&&(t=lowprimes.length);for(var n=nbi(),s=0;s=256||rng_pptr>=rng_psize)window.removeEventListener?window.removeEventListener("mousemove",onMouseMoveListener,!1):window.detachEvent&&window.detachEvent("onmousemove",onMouseMoveListener);else try{var e=t.x+t.y;rng_pool[rng_pptr++]=255&e,this.count+=1}catch(t){}};window.addEventListener?window.addEventListener("mousemove",onMouseMoveListener,!1):window.attachEvent&&window.attachEvent("onmousemove",onMouseMoveListener)}function rng_get_byte(){if(null==rng_state){for(rng_state=prng_newstate();rng_pptr=0&&e>0;){var s=t.charCodeAt(n--);s<128?r[--e]=s:s>127&&s<2048?(r[--e]=63&s|128,r[--e]=s>>6|192):(r[--e]=63&s|128,r[--e]=s>>6&63|128,r[--e]=s>>12|224)}if(r[--e]=0,2==i)for(var o=new SecureRandom,h=new Array;e>2;){for(h[0]=0;0==h[0];)o.nextBytes(h);r[--e]=h[0]}else if(0==i)r[--e]=0;else for(;e>2;)r[--e]=255;return r[--e]=i,r[--e]=0,new BigInteger(r)}function RSAKey(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}function RSASetPublic(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=parseBigInt(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")}function RSADoPublic(t){return t.modPowInt(this.e,this.n)}function RSAPublicEncrypt(t,e){var i=pkcs1pad2(t,this.n.bitLength()+7>>3,e);if(null==i)return null;var r=this.doPublic(i);if(null==r)return null;var n=r.toString(16);return 0==(1&n.length)?n:"0"+n}function RSAPrivateEncrypt(t,e){var i=pkcs1pad2(t,this.n.bitLength()+7>>3,e);if(null==i)return null;var r=this.doPrivate(i);if(null==r)return null;var n=r.toString(16);return 0==(1&n.length)?n:"0"+n}function pkcs1unpad2(t,e,i){var r=t.toByteArray(),n=0;if(0==i)n=-1;else{for(;n=r.length)return null}for(var s="";++n191&&o<224?(s+=String.fromCharCode((31&o)<<6|63&r[n+1]),++n):(s+=String.fromCharCode((15&o)<<12|(63&r[n+1])<<6|63&r[n+2]),n+=2)}return s}function RSASetPrivate(t,e,i){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=parseBigInt(t,16),this.e=parseInt(e,16),this.d=parseBigInt(i,16)):console.error("Invalid RSA private key")}function RSASetPrivateEx(t,e,i,r,n,s,o,h){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=parseBigInt(t,16),this.e=parseInt(e,16),this.d=parseBigInt(i,16),this.p=parseBigInt(r,16),this.q=parseBigInt(n,16),this.dmp1=parseBigInt(s,16),this.dmq1=parseBigInt(o,16),this.coeff=parseBigInt(h,16)):console.error("Invalid RSA private key")}function RSAGenerate(t,e){var i=new SecureRandom,r=t>>1;this.e=parseInt(e,16);for(var n=new BigInteger(e,16);;){for(;this.p=new BigInteger(t-r,1,i),0!=this.p.subtract(BigInteger.ONE).gcd(n).compareTo(BigInteger.ONE)||!this.p.isProbablePrime(10););for(;this.q=new BigInteger(r,1,i),0!=this.q.subtract(BigInteger.ONE).gcd(n).compareTo(BigInteger.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(BigInteger.ONE),h=this.q.subtract(BigInteger.ONE),a=o.multiply(h);if(0==a.gcd(n).compareTo(BigInteger.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(a),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(h),this.coeff=this.q.modInverse(this.p);break}}}function RSADoPrivate(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)}function RSAPrivateDecrypt(t,e){var i=parseBigInt(t,16),r=this.doPrivate(i);return null==r?null:pkcs1unpad2(r,this.n.bitLength()+7>>3,e)}function RSAPublicDecrypt(t,e){var i=parseBigInt(t,16),r=this.doPublic(i);return null==r?null:pkcs1unpad2(r,this.n.bitLength()+7>>3,e)}SecureRandom.prototype.nextBytes=rng_get_bytes,RSAKey.prototype.doPublic=RSADoPublic,RSAKey.prototype.setPublic=RSASetPublic,RSAKey.prototype.encrypt_public=RSAPublicEncrypt,RSAKey.prototype.encrypt_private=RSAPrivateEncrypt,RSAKey.prototype.doPrivate=RSADoPrivate,RSAKey.prototype.setPrivate=RSASetPrivate,RSAKey.prototype.setPrivateEx=RSASetPrivateEx,RSAKey.prototype.generate=RSAGenerate,RSAKey.prototype.decrypt_private=RSAPrivateDecrypt,RSAKey.prototype.decrypt_public=RSAPublicDecrypt,function(){RSAKey.prototype.generateAsync=function(t,e,i){var r=new SecureRandom,n=t>>1;this.e=parseInt(e,16);var s=new BigInteger(e,16),o=this,h=function(){var e=function(){if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(BigInteger.ONE),r=o.q.subtract(BigInteger.ONE),n=e.multiply(r);0==n.gcd(s).compareTo(BigInteger.ONE)?(o.n=o.p.multiply(o.q),o.d=s.modInverse(n),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(r),o.coeff=o.q.modInverse(o.p),setTimeout(function(){i()},0)):setTimeout(h,0)},a=function(){o.q=nbi(),o.q.fromNumberAsync(n,1,r,function(){o.q.subtract(BigInteger.ONE).gcda(s,function(t){0==t.compareTo(BigInteger.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(a,0)})})},u=function(){o.p=nbi(),o.p.fromNumberAsync(t-n,1,r,function(){o.p.subtract(BigInteger.ONE).gcda(s,function(t){0==t.compareTo(BigInteger.ONE)&&o.p.isProbablePrime(10)?setTimeout(a,0):setTimeout(u,0)})})};setTimeout(u,0)};setTimeout(h,0)};BigInteger.prototype.gcda=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var n=i;i=r,r=n}var s=i.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)e(i);else{s0&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var h=function(){(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),i.compareTo(r)>=0?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),i.signum()>0?setTimeout(h,0):(o>0&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(h,10)}};BigInteger.prototype.fromNumberAsync=function(t,e,i,r){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);var n=this,s=function(){n.dAddOffset(2,0),n.bitLength()>t&&n.subTo(BigInteger.ONE.shiftLeft(t-1),n),n.isProbablePrime(e)?setTimeout(function(){r()},0):setTimeout(s,0)};setTimeout(s,0)}else{var o=new Array,h=7&t;o.length=1+(t>>3),e.nextBytes(o),h>0?o[0]&=(1<>6)+b64map.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=b64map.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=b64map.charAt(i>>2)+b64map.charAt((3&i)<<4));(3&r.length)>0;)r+=b64pad;return r}function b64tohex(t){var e,i,r="",n=0;for(e=0;e>2),i=3&v,n=1):1==n?(r+=int2char(i<<2|v>>4),i=15&v,n=2):2==n?(r+=int2char(i),r+=int2char(v>>2),i=3&v,n=3):(r+=int2char(i<<2|v>>4),r+=int2char(15&v),n=0));return 1==n&&(r+=int2char(i<<2)),r}function b64toBA(t){var e,i=b64tohex(t),r=new Array;for(e=0;2*e15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},KJUR.asn1.DERAbstractString=function(t){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},JSX.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractTime=function(t){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e){var i=this.zeroPadding,r=this.localDateToUTC(t),n=String(r.getFullYear());return"utc"==e&&(n=n.substr(2,2)),n+i(String(r.getMonth()+1),2)+i(String(r.getDate()),2)+i(String(r.getHours()),2)+i(String(r.getMinutes()),2)+i(String(r.getSeconds()),2)+"Z"},this.zeroPadding=function(t,e){return t.length>=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(this.s)},this.setByDateValue=function(t,e,i,r,n,s){var o=new Date(Date.UTC(t,e-1,i,r,n,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},JSX.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object),KJUR.asn1.DERAbstractStructured=function(t){KJUR.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)},JSX.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object),KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},JSX.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object),KJUR.asn1.DERInteger=function(t){KJUR.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new BigInteger(String(t),10);this.setByBigInteger(e)},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):void 0!==t.hex&&this.setValueHex(t.hex))},JSX.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object),KJUR.asn1.DERBitString=function(t){KJUR.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=2?(s[s.length]=o,o=0,h=0):o<<=4}}if(h)throw"Hex encoding incomplete: 4 bits missing";return s},window.Hex=i}(),function(t){"use strict";var e,i={};i.decode=function(t){var i;if(void 0===e){var r="= \f\n\r\t?\u2028\u2029";for(e=[],i=0;i<64;++i)e["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(i)]=i;for(i=0;i=4?(n[n.length]=s>>16,n[n.length]=s>>8&255,n[n.length]=255&s,s=0,o=0):s<<=6}}switch(o){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:n[n.length]=s>>10;break;case 3:n[n.length]=s>>16,n[n.length]=s>>8&255}return n},i.re=/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,i.unarmor=function(t){var e=i.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw"RegExp out of sync";t=e[2]}return i.decode(t)},window.Base64=i}(),function(t){"use strict";var e=function(t,e){var i=document.createElement(t);return i.className=e,i},i=function(t){return document.createTextNode(t)};function r(t,e){t instanceof r?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}function n(t,e,i,r,n){this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=n}r.prototype.get=function(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw"Requesting byte offset "+t+" on a stream of length "+this.enc.length;return this.enc[t]},r.prototype.hexDigits="0123456789ABCDEF",r.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},r.prototype.hexDump=function(t,e,i){for(var r="",n=t;n191&&n<224?String.fromCharCode((31&n)<<6|63&this.get(r++)):String.fromCharCode((15&n)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return i},r.prototype.parseStringBMP=function(t,e){for(var i="",r=t;r4){i<<=3;var r=this.get(t);if(0===r)i-=8;else for(;r<128;)r<<=1,--i;return"("+i+" bit)"}for(var n=0,s=t;st;--o){for(var h=this.get(o),a=s;a<8;++a)n+=h>>a&1?"1":"0";s=0}}return n},r.prototype.parseOctetString=function(t,e){var i=e-t,r="("+i+" byte) ";i>100&&(e=t+100);for(var n=t;n100&&(r+="…"),r},r.prototype.parseOID=function(t,e){for(var i="",r=0,n=0,s=t;s=31?"bigint":r);r=n=0}}return i},n.prototype.typeName=function(){if(void 0===this.tag)return"unknown";var t=this.tag>>6,e=(this.tag,31&this.tag);switch(t){case 0:switch(e){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString";default:return"Universal_"+e.toString(16)}case 1:return"Application_"+e.toString(16);case 2:return"["+e+"]";case 3:return"Private_"+e.toString(16)}},n.prototype.reSeemsASCII=/^[ -~]+$/,n.prototype.content=function(){if(void 0===this.tag)return null;var t=this.tag>>6,e=31&this.tag,i=this.posContent(),r=Math.abs(this.length);if(0!==t){if(null!==this.sub)return"("+this.sub.length+" elem)";var n=this.stream.parseStringISO(i,i+Math.min(r,100));return this.reSeemsASCII.test(n)?n.substring(0,200)+(n.length>200?"…":""):this.stream.parseOctetString(i,i+r)}switch(e){case 1:return 0===this.stream.get(i)?"false":"true";case 2:return this.stream.parseInteger(i,i+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(i,i+r);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(i,i+r);case 6:return this.stream.parseOID(i,i+r);case 16:case 17:return"("+this.sub.length+" elem)";case 12:return this.stream.parseStringUTF(i,i+r);case 18:case 19:case 20:case 21:case 22:case 26:return this.stream.parseStringISO(i,i+r);case 30:return this.stream.parseStringBMP(i,i+r);case 23:case 24:return this.stream.parseTime(i,i+r)}return null},n.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},n.prototype.print=function(t){if(void 0===t&&(t=""),document.writeln(t+this),null!==this.sub){t+=" ";for(var e=0,i=this.sub.length;e=0&&(e+="+"),e+=this.length,32&this.tag?e+=" (constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var i=0,r=this.sub.length;i",n+="Length: "+this.header+"+",this.length>=0?n+=this.length:n+=-this.length+" (undefined)",32&this.tag?n+="
(constructed)":3!=this.tag&&4!=this.tag||null===this.sub||(n+="
(encapsulates)"),null!==s&&(n+="
Value:
"+s+"","object"==typeof oids&&6==this.tag)){var a=oids[s];a&&(a.d&&(n+="
"+a.d),a.c&&(n+="
"+a.c),a.w&&(n+="
(warning!)"))}h.innerHTML=n,t.appendChild(h);var u=e("div","sub");if(null!==this.sub)for(var p=0,c=this.sub.length;p=o)){var h=e("span",r);h.appendChild(i(n.hexDump(s,o))),t.appendChild(h)}},n.prototype.toHexDOM=function(t){var r=e("span","hex");if(void 0===t&&(t=r),this.head.hexNode=r,this.head.onmouseover=function(){this.hexNode.className="hexCurrent"},this.head.onmouseout=function(){this.hexNode.className="hex"},r.asn1=this,r.onmouseover=function(){var e=!t.selected;e&&(t.selected=this.asn1,this.className="hexCurrent"),this.asn1.fakeHover(e)},r.onmouseout=function(){var e=t.selected==this.asn1;this.asn1.fakeOut(e),e&&(t.selected=null,this.className="hex")},this.toHexDOM_sub(r,"tag",this.stream,this.posStart(),this.posStart()+1),this.toHexDOM_sub(r,this.length>=0?"dlen":"ulen",this.stream,this.posStart()+1,this.posContent()),null===this.sub)r.appendChild(i(this.stream.hexDump(this.posContent(),this.posEnd())));else if(this.sub.length>0){var n=this.sub[0],s=this.sub[this.sub.length-1];this.toHexDOM_sub(r,"intro",this.stream,this.posContent(),n.posStart());for(var o=0,h=this.sub.length;o3)throw"Length over 24 bits not supported at position "+(t.pos-1);if(0===i)return-1;e=0;for(var r=0;r4)return!1;var s=new r(i);if(3==t&&s.get(),s.get()>>6&1)return!1;try{var o=n.decodeLength(s);return s.pos-i.pos+o==e}catch(t){return!1}},n.decode=function(t){t instanceof r||(t=new r(t,0));var e=new r(t),i=t.get(),s=n.decodeLength(t),o=t.pos-e.pos,h=null;if(n.hasContent(i,s,t)){var a=t.pos;if(3==i&&t.get(),h=[],s>=0){for(var u=a+s;t.pos>3)-11;try{var lt="",ct="";if(string.length>maxLength)return lt=string.match(eval("/.{1,"+maxLength+"}/g")),lt.forEach(function(t){var e=k.encrypt_public(t,padding);ct+=e}),output?hex2b64(ct):ct;var t=k.encrypt_public(string,padding),y=output?hex2b64(t):t;return y}catch(t){return!1}},JSEncrypt.prototype.private_decryptLong=function(string,padding,output){var k=this.getKey(),maxLength=(k.n.bitLength()+7>>3)-11,MAX_DECRYPT_BLOCK=parseInt((k.n.bitLength()+1)/4);try{var ct="";if(string=output?b64tohex(string):string,string.length>maxLength){var lt=string.match(eval("/.{1,"+MAX_DECRYPT_BLOCK+"}/g"));return lt.forEach(function(t){var e=k.decrypt_private(t,padding);ct+=e}),ct}var y=k.decrypt_private(string,padding);return y}catch(t){return!1}},JSEncrypt.prototype.private_encryptLong=function(string,padding,output){var k=this.getKey(),maxLength=(k.n.bitLength()+7>>3)-11;try{var lt="",ct="";if(string.length>maxLength)return lt=string.match(eval("/.{1,"+maxLength+"}/g")),lt.forEach(function(t){var e=k.encrypt_private(t,padding);ct+=e}),output?hex2b64(ct):ct;var t=k.encrypt_private(string,padding),y=output?hex2b64(t):t;return y}catch(t){return!1}},JSEncrypt.prototype.public_decryptLong=function(string,padding,output){var k=this.getKey(),maxLength=(k.n.bitLength()+7>>3)-11,MAX_DECRYPT_BLOCK=parseInt((k.n.bitLength()+1)/4);try{var ct="";if(string=output?b64tohex(string):string,string.length>maxLength){var lt=string.match(eval("/.{1,"+MAX_DECRYPT_BLOCK+"}/g"));return lt.forEach(function(t){var e=k.decrypt_public(t,padding);ct+=e}),ct}var y=k.decrypt_public(string,padding);return y}catch(t){return!1}},JSEncrypt.version="2.3.0",exports.JSEncrypt=JSEncrypt}(RSA);};function RSA_Public_Encrypt(t){var public_key="MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgGvQoWu6RHLYoKD2ZPvf91NF6vBgwgha2XcTVZzJQ/swxOLwmOEfBDKPOAMqPlZr+gy03Sw5RXymHn8LZDQWjPtnQbkri/oEKEni63Yv/XQkFFpPdDT+YluIGCtNc7ljW1nFUuXGb6MRM1GmoCG8gKwvz3Xe4ei8Ml3bMxAqi9gVAgMBAAE=";var Crypt=new RSA.JSEncrypt;return Crypt.setPublicKey(public_key),Crypt.public_encryptLong(t,2,true)} function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;"POST"===e&&(s=this.post);const i=new Promise(((e,i)=>{s.call(this,t,((t,s,o)=>{t?i(t):e(s)}))}));return t.timeout?((t,e=1e3)=>Promise.race([t,new Promise(((t,s)=>{setTimeout((()=>{s(new Error("请求超时"))}),e)}))]))(i,t.timeout):i}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.logLevels={debug:0,info:1,warn:2,error:3},this.logLevelPrefixs={debug:"[DEBUG] ",info:"[INFO] ",warn:"[WARN] ",error:"[ERROR] "},this.logLevel="info",this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.encoding="utf-8",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}getEnv(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":void 0}isNode(){return"Node.js"===this.getEnv()}isQuanX(){return"Quantumult X"===this.getEnv()}isSurge(){return"Surge"===this.getEnv()}isLoon(){return"Loon"===this.getEnv()}isShadowrocket(){return"Shadowrocket"===this.getEnv()}isStash(){return"Stash"===this.getEnv()}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null,...s){try{return JSON.stringify(t,...s)}catch{return e}}getjson(t,e){let s=e;if(this.getdata(t))try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise((e=>{this.get({url:t},((t,s,i)=>e(i)))}))}runScript(t,e){return new Promise((s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=e&&e.timeout?e.timeout:o;const[r,a]=i.split("@"),n={url:`http://${a}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":r,Accept:"*/*"},policy:"DIRECT",timeout:o};this.post(n,((t,e,i)=>s(i)))})).catch((t=>this.logErr(t)))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),o=JSON.stringify(this.data);s?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(e,o):this.fs.writeFileSync(t,o)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return s;return o}lodash_set(t,e,s){return Object(t)!==t||(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce(((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{}),t)[e[e.length-1]]=s),t}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),o=s?this.getval(s):"";if(o)try{const t=JSON.parse(o);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(e),r=this.getval(i),a=i?"null"===r?null:r||"{}":"{}";try{const e=JSON.parse(a);this.lodash_set(e,o,t),s=this.setval(JSON.stringify(e),i)}catch(e){const r={};this.lodash_set(r,o,t),s=this.setval(JSON.stringify(r),i)}}else s=this.setval(t,e);return s}getval(t){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.read(t);case"Quantumult X":return $prefs.valueForKey(t);case"Node.js":return this.data=this.loaddata(),this.data[t];default:return this.data&&this.data[t]||null}}setval(t,e){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.write(t,e);case"Quantumult X":return $prefs.setValueForKey(t,e);case"Node.js":return this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0;default:return this.data&&this.data[e]||null}}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.cookie&&void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar)))}get(t,e=(()=>{})){switch(t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"],delete t.headers["content-type"],delete t.headers["content-length"]),t.params&&(t.url+="?"+this.queryStr(t.params)),void 0===t.followRedirect||t.followRedirect||((this.isSurge()||this.isLoon())&&(t["auto-redirect"]=!1),this.isQuanX()&&(t.opts?t.opts.redirection=!1:t.opts={redirection:!1})),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,((t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,i)}));break;case"Quantumult X":this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then((t=>{const{statusCode:s,statusCode:i,headers:o,body:r,bodyBytes:a}=t;e(null,{status:s,statusCode:i,headers:o,body:r,bodyBytes:a},r,a)}),(t=>e(t&&t.error||"UndefinedError")));break;case"Node.js":let s=require("iconv-lite");this.initGotEnv(t),this.got(t).on("redirect",((t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}})).then((t=>{const{statusCode:i,statusCode:o,headers:r,rawBody:a}=t,n=s.decode(a,this.encoding);e(null,{status:i,statusCode:o,headers:r,rawBody:a,body:n},n)}),(t=>{const{message:i,response:o}=t;e(i,o,o&&s.decode(o.rawBody,this.encoding))}));break}}post(t,e=(()=>{})){const s=t.method?t.method.toLocaleLowerCase():"post";switch(t.body&&t.headers&&!t.headers["Content-Type"]&&!t.headers["content-type"]&&(t.headers["content-type"]="application/x-www-form-urlencoded"),t.headers&&(delete t.headers["Content-Length"],delete t.headers["content-length"]),void 0===t.followRedirect||t.followRedirect||((this.isSurge()||this.isLoon())&&(t["auto-redirect"]=!1),this.isQuanX()&&(t.opts?t.opts.redirection=!1:t.opts={redirection:!1})),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient[s](t,((t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,i)}));break;case"Quantumult X":t.method=s,this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then((t=>{const{statusCode:s,statusCode:i,headers:o,body:r,bodyBytes:a}=t;e(null,{status:s,statusCode:i,headers:o,body:r,bodyBytes:a},r,a)}),(t=>e(t&&t.error||"UndefinedError")));break;case"Node.js":let i=require("iconv-lite");this.initGotEnv(t);const{url:o,...r}=t;this.got[s](o,r).then((t=>{const{statusCode:s,statusCode:o,headers:r,rawBody:a}=t,n=i.decode(a,this.encoding);e(null,{status:s,statusCode:o,headers:r,rawBody:a,body:n},n)}),(t=>{const{message:s,response:o}=t;e(s,o,o&&i.decode(o.rawBody,this.encoding))}));break}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).length)));return t}queryStr(t){let e="";for(const s in t){let i=t[s];null!=i&&""!==i&&("object"==typeof i&&(i=JSON.stringify(i)),e+=`${s}=${i}&`)}return e=e.substring(0,e.length-1),e}msg(e=t,s="",i="",o={}){const r=t=>{const{$open:e,$copy:s,$media:i,$mediaMime:o}=t;switch(typeof t){case void 0:return t;case"string":switch(this.getEnv()){case"Surge":case"Stash":default:return{url:t};case"Loon":case"Shadowrocket":return t;case"Quantumult X":return{"open-url":t};case"Node.js":return}case"object":switch(this.getEnv()){case"Surge":case"Stash":case"Shadowrocket":default:{const r={};let a=t.openUrl||t.url||t["open-url"]||e;a&&Object.assign(r,{action:"open-url",url:a});let n=t["update-pasteboard"]||t.updatePasteboard||s;if(n&&Object.assign(r,{action:"clipboard",text:n}),i){let t,e,s;if(i.startsWith("http"))t=i;else if(i.startsWith("data:")){const[t]=i.split(";"),[,o]=i.split(",");e=o,s=t.replace("data:","")}else{e=i,s=(t=>{const e={JVBERi0:"application/pdf",R0lGODdh:"image/gif",R0lGODlh:"image/gif",iVBORw0KGgo:"image/png","/9j/":"image/jpg"};for(var s in e)if(0===t.indexOf(s))return e[s];return null})(i)}Object.assign(r,{"media-url":t,"media-base64":e,"media-base64-mime":o??s})}return Object.assign(r,{"auto-dismiss":t["auto-dismiss"],sound:t.sound}),r}case"Loon":{const s={};let o=t.openUrl||t.url||t["open-url"]||e;o&&Object.assign(s,{openUrl:o});let r=t.mediaUrl||t["media-url"];return i?.startsWith("http")&&(r=i),r&&Object.assign(s,{mediaUrl:r}),console.log(JSON.stringify(s)),s}case"Quantumult X":{const o={};let r=t["open-url"]||t.url||t.openUrl||e;r&&Object.assign(o,{"open-url":r});let a=t["media-url"]||t.mediaUrl;i?.startsWith("http")&&(a=i),a&&Object.assign(o,{"media-url":a});let n=t["update-pasteboard"]||t.updatePasteboard||s;return n&&Object.assign(o,{"update-pasteboard":n}),console.log(JSON.stringify(o)),o}case"Node.js":return}default:return}};if(!this.isMute)switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":default:$notification.post(e,s,i,r(o));break;case"Quantumult X":$notify(e,s,i,r(o));break;case"Node.js":break}if(!this.isMuteLog){let t=["","==============📣系统通知📣=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}debug(...t){this.logLevels[this.logLevel]<=this.logLevels.debug&&(t.length>0&&(this.logs=[...this.logs,...t]),console.log(`${this.logLevelPrefixs.debug}${t.map((t=>t??String(t))).join(this.logSeparator)}`))}info(...t){this.logLevels[this.logLevel]<=this.logLevels.info&&(t.length>0&&(this.logs=[...this.logs,...t]),console.log(`${this.logLevelPrefixs.info}${t.map((t=>t??String(t))).join(this.logSeparator)}`))}warn(...t){this.logLevels[this.logLevel]<=this.logLevels.warn&&(t.length>0&&(this.logs=[...this.logs,...t]),console.log(`${this.logLevelPrefixs.warn}${t.map((t=>t??String(t))).join(this.logSeparator)}`))}error(...t){this.logLevels[this.logLevel]<=this.logLevels.error&&(t.length>0&&(this.logs=[...this.logs,...t]),console.log(`${this.logLevelPrefixs.error}${t.map((t=>t??String(t))).join(this.logSeparator)}`))}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.map((t=>t??String(t))).join(this.logSeparator))}logErr(t,e){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":case"Quantumult X":default:this.log("",`❗️${this.name}, 错误!`,e,t);break;case"Node.js":this.log("",`❗️${this.name}, 错误!`,e,void 0!==t.message?t.message:t,t.stack);break}}wait(t){return new Promise((e=>setTimeout(e,t)))}done(t={}){const e=((new Date).getTime()-this.startTime)/1e3;switch(this.log("",`🔔${this.name}, 结束! 🕛 ${e} 秒`),this.log(),this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":case"Quantumult X":default:$done(t);break;case"Node.js":process.exit(1)}}}(t,e)}