mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
✨ 扫码登录
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* @file web/constant/bbs.ts
|
||||
* @description 常量-应用数据
|
||||
* @since Beta v0.6.7
|
||||
* @since Beta v0.6.8
|
||||
*/
|
||||
|
||||
export const BBS_VERSION: Readonly<string> = "2.79.1";
|
||||
export const BBS_VERSION: Readonly<string> = "2.80.1";
|
||||
export const BBS_UA_MOBILE: Readonly<string> = `Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBS/${BBS_VERSION}`;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
/**
|
||||
* @file web/request/passportReq.ts
|
||||
* @description Passport 相关请求
|
||||
* @since Beta v0.6.3
|
||||
* @since Beta v0.6.8
|
||||
*/
|
||||
import TGHttp from "@/utils/TGHttp.js";
|
||||
import { getDeviceInfo } from "@/utils/toolFunc.js";
|
||||
import { getRequestHeader } from "@/web/utils/getRequestHeader.js";
|
||||
|
||||
// PassportApiBaseUrl => pAbu
|
||||
const pAbu: Readonly<string> = "https://passport-api.mihoyo.com/";
|
||||
// PassportV4ApiBaseUrl => p4Abu
|
||||
const p4Abu: Readonly<string> = "https://passport-api-v4.mihoyo.com/";
|
||||
// HoyoLauncherVersion
|
||||
const hlv: Readonly<string> = "1.3.3.182";
|
||||
|
||||
/**
|
||||
* @description 获取登录ticket
|
||||
@@ -40,6 +43,30 @@ async function createAuthTicketByGameBiz(
|
||||
return resp.data.ticket;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 创建登录二维码
|
||||
* @since Beta v0.6.8
|
||||
* @returns {Promise<TGApp.BBS.Response.Base|TGApp.BBS.GameLogin.GetLoginQrData>}
|
||||
*/
|
||||
async function createQrLogin(): Promise<
|
||||
TGApp.BBS.Response.Base | TGApp.BBS.GameLogin.GetLoginQrData
|
||||
> {
|
||||
const resp = await TGHttp<TGApp.BBS.GameLogin.GetLoginQrResponse>(
|
||||
`${pAbu}account/ma-cn-passport/app/createQRLogin`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"x-rpc-device_id": getDeviceInfo("device_id"),
|
||||
"user-agent": `HYPContainer/${hlv}`,
|
||||
"x-rpc-app_id": "ddxf5dufpuyo",
|
||||
"x-rpc-client_type": "3",
|
||||
},
|
||||
},
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据 stoken 获取 cookie_token
|
||||
* @since Beta v0.6.3
|
||||
@@ -78,6 +105,32 @@ async function getLTokenBySToken(
|
||||
return resp.data.ltoken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取登录状态
|
||||
* @since Beta v0.6.8
|
||||
* @param {string} ticket - 二维码 ticket
|
||||
* @returns {Promise<TGApp.BBS.Response.Base|TGApp.BBS.GameLogin.GetLoginStatusData>}
|
||||
*/
|
||||
async function queryLoginStatus(
|
||||
ticket: string,
|
||||
): Promise<TGApp.BBS.Response.Base | TGApp.BBS.GameLogin.GetLoginStatusData> {
|
||||
const resp = await TGHttp<TGApp.BBS.GameLogin.GetLoginStatusResponse>(
|
||||
`${pAbu}account/ma-cn-passport/app/queryQRLoginStatus`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"x-rpc-device_id": getDeviceInfo("device_id"),
|
||||
"user-agent": `HYPContainer/${hlv}`,
|
||||
"x-rpc-app_id": "ddxf5dufpuyo",
|
||||
"x-rpc-client_type": "3",
|
||||
},
|
||||
body: JSON.stringify({ ticket }),
|
||||
},
|
||||
);
|
||||
if (resp.retcode !== 0) return <TGApp.BBS.Response.Base>resp;
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 验证 ltoken 有效性,返回 mid
|
||||
* @since Beta v0.6.5
|
||||
@@ -102,6 +155,7 @@ const PassportApi = {
|
||||
authTicket: createAuthTicketByGameBiz,
|
||||
cookieToken: getCookieAccountInfoBySToken,
|
||||
lToken: { get: getLTokenBySToken, verify: verifyLToken },
|
||||
qrLogin: { create: createQrLogin, query: queryLoginStatus },
|
||||
};
|
||||
|
||||
export default PassportApi;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file web/utils/getRequestHeader.ts
|
||||
* @description 获取请求头
|
||||
* @since Beta v0.6.7
|
||||
* @since Beta v0.6.8
|
||||
*/
|
||||
|
||||
import Md5 from "js-md5";
|
||||
@@ -24,12 +24,12 @@ const enum SaltType {
|
||||
|
||||
/**
|
||||
* @description salt 值
|
||||
* @version 2.79.1
|
||||
* @version 2.80.1
|
||||
* @since Beta v0.6.7
|
||||
*/
|
||||
const Salt: Readonly<Record<keyof typeof SaltType, string>> = {
|
||||
K2: "eOzxpHXVGBVdFBtkbkTvwyCgRpqRFeBr",
|
||||
LK2: "AbuxbruiFDIgxLXksUNMAMvDyciznofM",
|
||||
K2: "G1rXOpMLQS77VPWEGycOSxekCTZe2Q8M",
|
||||
LK2: "sd1e1gQJuvqBfZxas1oeAACXzbim5cge",
|
||||
X4: "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs",
|
||||
X6: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
|
||||
PROD: "t0qEgfub6cvueAPgR5m9aQWWVciEer7v",
|
||||
|
||||
Reference in New Issue
Block a user