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

修正获取stoken方法 兼容V2 V3最新版本

This commit is contained in:
Ctrlcvs 2022-07-29 15:02:43 +08:00 committed by leiyilu
parent 454b18d780
commit 3bafc24416

View File

@ -4,7 +4,9 @@ import _ from 'lodash';
import superagent from 'superagent';
import fs from "fs";
import YAML from 'yaml'
import {Data} from "../../components/index.js";
import {
Data
} from "../../components/index.js";
import fetch from "node-fetch"
const APP_VERSION = "2.2.0";
const DEVICE_ID = utils.randomString(32).toUpperCase();
@ -73,7 +75,7 @@ export default class MihoYoApi {
}
const map = this.getCookieMap(cookie);
const loginTicket = map.get("login_ticket");
const loginUid = map.get("login_uid");
const loginUid = map.get("login_uid") ? map.get("login_uid") : map.get("ltuid");
const url = "https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?login_ticket=" +
loginTicket + "&token_types=3&uid=" + loginUid;
fetch(url, {
@ -140,11 +142,12 @@ export default class MihoYoApi {
}
getCookieMap(cookie) {
let cookiePattern = /^(\S+)=(\S+)$/;
let cookieArray = cookie.split("; ");
let cookieArray = cookie.replace(/\s*/g,"").split(";");
let cookieMap = new Map();
for (let item of cookieArray) {
let entry = cookiePattern.exec(item);
cookieMap.set(entry[1], entry[2]);
let entry = item.split("=");
if(!entry[0]) continue;
cookieMap.set(entry[0], entry[1]);
}
return cookieMap;
}