mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 11:40:51 +08:00
修正获取stoken方法 兼容V2 V3最新版本
This commit is contained in:
parent
454b18d780
commit
3bafc24416
@ -4,7 +4,9 @@ import _ from 'lodash';
|
|||||||
import superagent from 'superagent';
|
import superagent from 'superagent';
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import YAML from 'yaml'
|
import YAML from 'yaml'
|
||||||
import {Data} from "../../components/index.js";
|
import {
|
||||||
|
Data
|
||||||
|
} from "../../components/index.js";
|
||||||
import fetch from "node-fetch"
|
import fetch from "node-fetch"
|
||||||
const APP_VERSION = "2.2.0";
|
const APP_VERSION = "2.2.0";
|
||||||
const DEVICE_ID = utils.randomString(32).toUpperCase();
|
const DEVICE_ID = utils.randomString(32).toUpperCase();
|
||||||
@ -73,7 +75,7 @@ export default class MihoYoApi {
|
|||||||
}
|
}
|
||||||
const map = this.getCookieMap(cookie);
|
const map = this.getCookieMap(cookie);
|
||||||
const loginTicket = map.get("login_ticket");
|
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=" +
|
const url = "https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?login_ticket=" +
|
||||||
loginTicket + "&token_types=3&uid=" + loginUid;
|
loginTicket + "&token_types=3&uid=" + loginUid;
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
@ -140,11 +142,12 @@ export default class MihoYoApi {
|
|||||||
}
|
}
|
||||||
getCookieMap(cookie) {
|
getCookieMap(cookie) {
|
||||||
let cookiePattern = /^(\S+)=(\S+)$/;
|
let cookiePattern = /^(\S+)=(\S+)$/;
|
||||||
let cookieArray = cookie.split("; ");
|
let cookieArray = cookie.replace(/\s*/g,"").split(";");
|
||||||
let cookieMap = new Map();
|
let cookieMap = new Map();
|
||||||
for (let item of cookieArray) {
|
for (let item of cookieArray) {
|
||||||
let entry = cookiePattern.exec(item);
|
let entry = item.split("=");
|
||||||
cookieMap.set(entry[1], entry[2]);
|
if(!entry[0]) continue;
|
||||||
|
cookieMap.set(entry[0], entry[1]);
|
||||||
}
|
}
|
||||||
return cookieMap;
|
return cookieMap;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user