mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
@@ -1,17 +1,18 @@
|
||||
/**
|
||||
* @file web constant TGConstant.ts
|
||||
* @file web/constant/TGConstant.ts
|
||||
* @description 常量
|
||||
* @since Beta v0.3.3
|
||||
* @since Beta v0.3.6
|
||||
*/
|
||||
|
||||
import { BBS_VERSION, BBS_HEADER_AGENT, BBS_APP_ID, BBS_SALT } from "./bbs";
|
||||
import { BBS_APP_ID, BBS_SALT, BBS_UA_MOBILE, BBS_UA_PC, BBS_VERSION } from "./bbs";
|
||||
import SERVER from "./server";
|
||||
import { GAME_BIZ } from "./utils";
|
||||
|
||||
const TGConstant = {
|
||||
BBS: {
|
||||
VERSION: BBS_VERSION,
|
||||
USER_AGENT: BBS_HEADER_AGENT,
|
||||
UA_PC: BBS_UA_PC,
|
||||
UA_MOBILE: BBS_UA_MOBILE,
|
||||
APP_ID: BBS_APP_ID,
|
||||
},
|
||||
Salt: BBS_SALT,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* @file web constant bbs.ts
|
||||
* @file web/constant/bbs.ts
|
||||
* @description 常量-应用数据
|
||||
* @since Beta v0.3.3
|
||||
* @since Beta v0.3.6
|
||||
*/
|
||||
|
||||
export const BBS_VERSION = "2.59.1";
|
||||
export const BBS_HEADER_AGENT = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/${BBS_VERSION}`;
|
||||
export const BBS_UA_PC = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) miHoYoBBS/${BBS_VERSION}`;
|
||||
export const BBS_UA_MOBILE = `Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBS/${BBS_VERSION}`;
|
||||
export const BBS_APP_ID = "bll8iq97cem8";
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web request TGRequest.ts
|
||||
* @file web/request/TGRequest.ts
|
||||
* @description 应用用到的请求函数
|
||||
* @since Beta v0.3.4
|
||||
* @since Beta v0.3.6
|
||||
*/
|
||||
|
||||
import { genAuthkey } from "./genAuthkey";
|
||||
@@ -9,6 +9,7 @@ import { getAbyss } from "./getAbyss";
|
||||
import { getActionTicketBySToken } from "./getActionTicket";
|
||||
import { getAnnoContent, getAnnoList } from "./getAnno";
|
||||
import { getCookieTokenByGameToken, getCookieTokenBySToken } from "./getCookieToken";
|
||||
import { getDeviceFp } from "./getDeviceFp";
|
||||
// import * from "./getEnkaData.ts";
|
||||
import { getGachaLog } from "./getGachaLog";
|
||||
import { getGameAccountsByCookie, getGameAccountsBySToken } from "./getGameAccounts";
|
||||
@@ -27,6 +28,9 @@ const TGRequest = {
|
||||
getList: getAnnoList,
|
||||
getContent: getAnnoContent,
|
||||
},
|
||||
Device: {
|
||||
getFp: getDeviceFp,
|
||||
},
|
||||
User: {
|
||||
getAuthkey: genAuthkey,
|
||||
getGachaLog,
|
||||
|
||||
82
src/web/request/getDeviceFp.ts
Normal file
82
src/web/request/getDeviceFp.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* @file src/web/request/getDeviceFp.ts
|
||||
* @description 获取设备指纹
|
||||
* @since Beta v0.3.6
|
||||
*/
|
||||
|
||||
import { http } from "@tauri-apps/api";
|
||||
|
||||
import { getInitDeviceInfo } from "../../utils/toolFunc";
|
||||
import TGConstant from "../constant/TGConstant";
|
||||
|
||||
/**
|
||||
* @description 获取设备指纹
|
||||
* @since Beta v0.3.6
|
||||
* @returns {Promise<TGApp.BBS.Response.getDeviceFp>} 设备指纹
|
||||
*/
|
||||
export async function getDeviceFp(): Promise<void> {
|
||||
const info = getInitDeviceInfo();
|
||||
const deviceFPHeader = {
|
||||
cpuType: "arm64-v8a",
|
||||
romCapacity: "512",
|
||||
productName: info.model,
|
||||
romRemain: "256",
|
||||
manufacturer: "Xiaomi",
|
||||
appMemory: "512",
|
||||
hostname: "dg02-pool03-kvm87",
|
||||
screenSize: "1080x1920",
|
||||
osVersion: "13",
|
||||
aaid: "",
|
||||
vendor: "中国移动",
|
||||
accelerometer: "true",
|
||||
buildTags: "release-keys",
|
||||
model: info.model,
|
||||
brand: "Xiaomi",
|
||||
oaid: "",
|
||||
hardware: "qcom",
|
||||
deviceType: "OP5913L1",
|
||||
devId: "unknown",
|
||||
serialNumber: "unknown",
|
||||
buildTime: "1588876800000", // 2020-05-08
|
||||
buildUser: "root",
|
||||
ramCapacity: "2048",
|
||||
magnetometer: "true",
|
||||
display: `OP5913L1-user ${info.model} 10 QKQ1.190825.002 V12.0.1.0.QFJCNXM release-keys`,
|
||||
ramRemain: "1024",
|
||||
deviceInfo: "unknown",
|
||||
gyroscope: "true",
|
||||
vaid: "",
|
||||
buildType: "user",
|
||||
sdkVersion: "29",
|
||||
board: "sdm660",
|
||||
};
|
||||
const url = "https://public-data-api.mihoyo.com/device-fp/api/getFp";
|
||||
const data = {
|
||||
device_id: info.device_id,
|
||||
seed_id: info.seed_id,
|
||||
platform: "2",
|
||||
seed_time: info.seed_time,
|
||||
ext_fields: JSON.stringify(deviceFPHeader),
|
||||
app_name: "bbs_cn",
|
||||
bbs_device_id: info.device_id,
|
||||
device_fp: info.device_fp,
|
||||
};
|
||||
const header = {
|
||||
"User-Agent": `Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBS/${TGConstant.BBS.VERSION}`,
|
||||
"x-rpc-app_version": TGConstant.BBS.VERSION,
|
||||
"x-rpc-client_type": "5",
|
||||
"x-requested-with": "com.mihoyo.hyperion",
|
||||
Referer: "https://webstatic.mihoyo.com/",
|
||||
};
|
||||
info.device_fp = await http
|
||||
.fetch<TGApp.BBS.Response.getDeviceFp>(url, {
|
||||
method: "POST",
|
||||
body: http.Body.json(data),
|
||||
headers: header,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.data.data.code === 200) return res.data.data.device_fp;
|
||||
return "0000000000000";
|
||||
});
|
||||
localStorage.setItem("deviceInfo", JSON.stringify({ deviceInfo: info }));
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
/**
|
||||
* @file web utils getRequestHeader.ts
|
||||
* @file web/utils/getRequestHeader.ts
|
||||
* @description 获取请求头
|
||||
* @since Beta v0.3.4
|
||||
* @since Beta v0.3.6
|
||||
*/
|
||||
|
||||
import Md5 from "js-md5";
|
||||
|
||||
import { transCookie, transParams } from "./tools";
|
||||
import { getDeviceInfo, getRandomString } from "../../utils/toolFunc";
|
||||
import TGConstant from "../constant/TGConstant";
|
||||
|
||||
/**
|
||||
@@ -40,21 +41,6 @@ function getRandomNumber(min: number, max: number): number {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取随机字符串
|
||||
* @since Alpha v0.2.0
|
||||
* @param {number} length 字符串长度
|
||||
* @returns {string} 随机字符串
|
||||
*/
|
||||
function getRandomString(length: number): string {
|
||||
const str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
let res = "";
|
||||
for (let i = 0; i < length; i++) {
|
||||
res += str.charAt(Math.floor(Math.random() * str.length));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取 ds
|
||||
* @since Beta v0.3.3
|
||||
@@ -80,7 +66,7 @@ function getDS(method: string, data: string, saltType: string, isSign: boolean):
|
||||
|
||||
/**
|
||||
* @description 获取请求头
|
||||
* @since Beta v0.3.0
|
||||
* @since Beta v0.3.6
|
||||
* @param {Record<string, string>} cookie cookie
|
||||
* @param {string} method 请求方法
|
||||
* @param {Record<string, string|number>|string} data 请求数据
|
||||
@@ -102,11 +88,13 @@ export function getRequestHeader(
|
||||
ds = getDS(method, transParams(data), saltType, isSign);
|
||||
}
|
||||
return {
|
||||
"user-agent": TGConstant.BBS.USER_AGENT,
|
||||
"user-agent": TGConstant.BBS.UA_PC,
|
||||
"x-rpc-app_version": TGConstant.BBS.VERSION,
|
||||
"x-rpc-client_type": "5",
|
||||
"x-requested-with": "com.mihoyo.hyperion",
|
||||
referer: "https://webstatic.mihoyo.com",
|
||||
"x-rpc-device_id": getDeviceInfo("device_id"),
|
||||
"x-rpc-device_fp": getDeviceInfo("device_fp"),
|
||||
ds,
|
||||
cookie: transCookie(cookie),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user