MCPcopy Create free account
hub / github.com/ClydeTime/Surge / autoLogin

Function autoLogin

Script/Task/CCBLife.js:101–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

99
100// 刷新 session
101async function autoLogin() {
102 let opt = {
103 url: `https://yunbusiness.ccb.com/clp_service/txCtrl?txcode=autoLogin`,
104 headers: {
105 'AppVersion': AppVersion,
106 'Content-Type': `application/json`,
107 'DeviceId': $.DeviceId,
108 'Accept': `application/json`,
109 'MBC-User-Agent': $.MBCUserAgent,
110 'Cookie': ''
111 },
112 body: $.ALBody
113 }
114 return new Promise(resolve => {
115 $.post(opt, async (error, response, data) => {
116 try {
117 let result = $.toObj(data) || response.body;
118 // 如果数据未加密,则 session 未过期
119 if (result?.errCode) {
120 // {"newErrMsg":"未能处理您的请求。如有疑问,请咨询在线客服或致电95533","data":"","reqFlowNo":"","errCode":"0","errMsg":"session未失效,勿重复登录"}
121 // $.token = $.getdata('JHSH_TOKEN');
122 $.log(`${result?.errMsg}`);
123 } else {
124 const set_cookie = response.headers['set-cookie'] || response.headers['Set-cookie'] || response.headers['Set-Cookie'];
125 // !$.isNode() ? $.setdata($.token, 'JHSH_TOKEN') : ''; // 数据持久化
126 let new_cookie = $.toStr(set_cookie).match(/SESSION=([a-f0-9-]+);/);
127 if (new_cookie) {
128 $.token = new_cookie[0];
129 $.log(`✅ 刷新 session 成功!`);
130 } else {
131 message += `❌ 账号 [${$.info?.USR_TEL ? hideSensitiveData($.info?.USR_TEL, 3, 4) : '🤒匿名用户'}] 刷新 session 失败,请重新获取Cookie。\n`;
132 $.log(`⛔️ 刷新 session 失败`);
133 }
134 }
135 } catch (error) {
136 $.log(error);
137 } finally {
138 resolve()
139 }
140 });
141 })
142}
143
144// 签到主函数
145function main() {

Callers 1

CCBLife.jsFile · 0.85

Calls 5

hideSensitiveDataFunction · 0.85
postMethod · 0.45
toObjMethod · 0.45
logMethod · 0.45
toStrMethod · 0.45

Tested by

no test coverage detected