2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00

支持v1sk绑定自动转换v2sk

This commit is contained in:
Ctrlcvs 2022-12-10 18:05:04 +08:00
parent d001517b06
commit d6042d7d4f
4 changed files with 40 additions and 11 deletions

View File

@ -207,6 +207,7 @@ export async function mytoken(e) {
await user.getCookie(e) await user.getCookie(e)
ck = await user.getStoken(e.user_id) ck = await user.getStoken(e.user_id)
sendMsg = `stuid=${ck.stuid};stoken=${ck.stoken};ltoken=${ck.ltoken};`; sendMsg = `stuid=${ck.stuid};stoken=${ck.stoken};ltoken=${ck.ltoken};`;
if (ck?.mid) sendMsg += `mid=${ck?.mid};`
} else { } else {
ck = await user.getyunToken(e); ck = await user.getyunToken(e);
sendMsg = `${ck.yuntoken}devId=${ck.devId}` sendMsg = `${ck.yuntoken}devId=${ck.devId}`

View File

@ -238,6 +238,12 @@ export default class miHoYoApi {
url: `${mys.pass_api}/account/auth/api/getLTokenBySToken`, url: `${mys.pass_api}/account/auth/api/getLTokenBySToken`,
query: `${data.cookies}`, query: `${data.cookies}`,
}, },
getByStokenV2: {
url: `${mys.pass_api}/account/ma-cn-session/app/getTokenBySToken`,
body: {},
types: 'pass'
},
} }
if (!urlMap[type]) return false if (!urlMap[type]) return false
let { let {
@ -373,6 +379,26 @@ export default class miHoYoApi {
"x-rpc-channel": "appstore", "x-rpc-channel": "appstore",
} }
break; break;
case "pass":
header = {
'x-rpc-device_id': DEVICE_ID,
'x-rpc-app_id': "bll8iq97cem8",
'x-rpc-device_name': DEVICE_NAME,
'x-rpc-app_version': mys.APP_VERSION,
'x-rpc-game_biz': 'bbs_cn',
"Content-Type": "application/json;",
"x-rpc-client_type": "2",
"DS": this.getDs2('', {}, mys.passSalt),
"x-rpc-sdk_version": '1.3.1.2',
"User-Agent": "okhttp/4.9.3",
"Referer": "cors",
'Host': 'passport-api.mihoyo.com',
"Connection": 'Keep-Alive',
"Accept-Encoding": "gzip, deflate, br",
"x-rpc-channel": "appstore",
Cookie: this.cookies,
}
break;
default: default:
header = {} header = {}
break; break;

View File

@ -1,8 +1,8 @@
const APP_VERSION = "2.38.1"; const APP_VERSION = "2.40.1";
const mhyVersion = "2.11.1"; const mhyVersion = "2.11.1";
const salt = "PVeGWIZACpxXZ1ibMVJPi9inCY4Nd4y2"; const salt = "fdv0fY9My9eA7MR0NpjGP9RjueFvjUSQ"; //k2
const salt2 = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v"; const salt2 = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v"; //x6
const saltWeb = "yUZ3s0Sna1IrSNfk29Vo6vRapdOyqyhB"; const saltWeb = "jEpJb9rRARU2rXDA9qYbZ3selxkuct9a";//lk2
const oldsalt = "z8DRIUjNDT7IT5IZXvrUAxyupA1peND9"; const oldsalt = "z8DRIUjNDT7IT5IZXvrUAxyupA1peND9";
const passSalt='JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS'; const passSalt='JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS';
const osSalt= ''; //599uqkwc0dlqu3h6epzjzfhgyyrd44ae rk4xg2hakoi26nljpr099fv9fck1ah10 const osSalt= ''; //599uqkwc0dlqu3h6epzjzfhgyyrd44ae rk4xg2hakoi26nljpr099fv9fck1ah10
@ -220,6 +220,6 @@ export default {
os_hk4_api, os_hk4_api,
hk4_api, hk4_api,
bbs_api, bbs_api,
pass_api, pass_api,passSalt,
boards boards
} }

View File

@ -240,7 +240,6 @@ export default class user {
name: "原神" name: "原神"
}) })
if (!res?.data) { if (!res?.data) {
console.log(res)
res.message = `登录Stoken失效请重新获取cookies或stoken保存~`; res.message = `登录Stoken失效请重新获取cookies或stoken保存~`;
res.isOk = false; res.isOk = false;
this.delSytk(yamlDataUrl, this.e) this.delSytk(yamlDataUrl, this.e)
@ -749,13 +748,15 @@ export default class user {
} }
} }
async seachUid(data) { async seachUid(data) {
let ltoken = '' let ltoken = '',v2Sk;
if (data?.data) { if (data?.data) {
let res; let res;
if (this.e.sk) { if (this.e.sk) {
if(this.e.sk.get('stoken').includes('v2_')){ if(this.e.sk.get('stoken').includes('v2_')){
res=await this.getData('getLtoken',{cookies:this.e.raw_message},false) res=await this.getData('getLtoken',{cookies:this.e.raw_message},false)
ltoken=res?.data?.ltoken ltoken=res?.data?.ltoken
}else{
v2Sk=await this.getData('getByStokenV2',{headers:{Cookie:this.e.raw_message}},false)
} }
this.e.cookie = this.e.cookie =
`ltoken=${this.e.sk?.get('ltoken') || ltoken};ltuid=${this.e.sk?.get('stuid')};cookie_token=${data.data.cookie_token}; account_id=${this.e.sk?.get('stuid')};` `ltoken=${this.e.sk?.get('ltoken') || ltoken};ltuid=${this.e.sk?.get('stuid')};cookie_token=${data.data.cookie_token}; account_id=${this.e.sk?.get('stuid')};`
@ -763,6 +764,7 @@ export default class user {
// this.e.cookie = // this.e.cookie =
// `ltoken_v2=${this.e.sk?.get('ltoken')||ltoken};cookie_token_v2=${data.data.cookie_token}; account_mid_v2=${this.e.sk.get('mid')};ltmid_v2=${this.e.sk.get('mid')}` // `ltoken_v2=${this.e.sk?.get('ltoken')||ltoken};cookie_token_v2=${data.data.cookie_token}; account_mid_v2=${this.e.sk.get('mid')};ltmid_v2=${this.e.sk.get('mid')}`
// } // }
} else { } else {
this.e.cookie = this.e.original_msg this.e.cookie = this.e.original_msg
} }
@ -777,9 +779,9 @@ export default class user {
uids.push(uid) uids.push(uid)
datalist[uid] = { datalist[uid] = {
stuid: this.e?.sk?.get('stuid') || this.e.stuid, stuid: this.e?.sk?.get('stuid') || this.e.stuid,
stoken: this.e?.sk?.get('stoken') || data?.data?.list[0].token, stoken:v2Sk?.data?.token?.token || this.e?.sk?.get('stoken') || data?.data?.list[0].token,
ltoken: this.e?.sk?.get('ltoken') || ltoken || data?.data?.list[1].token, ltoken: this.e?.sk?.get('ltoken') || ltoken || data?.data?.list[1].token,
mid: this.e?.sk?.get('mid'), mid: this.e?.sk?.get('mid')||v2Sk?.data?.user_info?.mid,
uid: uid, uid: uid,
userId: this.e.user_id, userId: this.e.user_id,
is_sign: true is_sign: true