重置胡桃云密码

This commit is contained in:
BTMuli
2026-01-12 23:26:38 +08:00
parent 2a9c0ab552
commit 44dd81463b
8 changed files with 464 additions and 26 deletions

View File

@@ -12,7 +12,13 @@ import {
getTeamCollect,
uploadAbyssData,
} from "./request/abyssReq.js";
import { getUserInfo, loginPassport, refreshToken } from "./request/accountReq.js";
import {
getResetPwdCode,
getUserInfo,
loginPassport,
refreshToken,
resetPwd,
} from "./request/accountReq.js";
import { getCombatStatistic, uploadCombatData } from "./request/combatReq.js";
import {
deleteGachaLogs,
@@ -50,11 +56,16 @@ const Hutao = {
Account: {
register: _,
login: loginPassport,
verify: _,
verify: {
username: _,
usernameNew: _,
pwd: getResetPwdCode,
cancel: _,
},
cancel: _,
reset: {
username: _,
password: _,
pwd: resetPwd,
},
info: getUserInfo,
},

View File

@@ -14,7 +14,7 @@ const PassportUrl = "https://homa.gentle.house/Passport/v2/";
* @since Beta v0.9.1
* @param username - 用户名(邮箱)
* @param password - 密码
* @returns
* @returns 登录返回
*/
export async function loginPassport(
username: string,
@@ -38,6 +38,7 @@ export async function loginPassport(
/**
* 刷新访问令牌
* @since Beta v0.9.1
* @returns 令牌返回
*/
export async function refreshToken(token: string) {
const url = `${PassportUrl}RefreshToken`;
@@ -55,6 +56,7 @@ export async function refreshToken(token: string) {
/**
* 获取用户信息
* @since Beta v0.9.1
* @returns 用户信息返回
*/
export async function getUserInfo(
token: string,
@@ -68,3 +70,61 @@ export async function getUserInfo(
if (resp.retcode !== 0) return <TGApp.Plugins.Hutao.Base.Resp>resp;
return <TGApp.Plugins.Hutao.Account.InfoRes>resp.data;
}
/**
* 获取充值密码验证码
* @since Beta v0.9.1
* @param username - 用户
* @returns 验证码返回
*/
export async function getResetPwdCode(username: string): Promise<TGApp.Plugins.Hutao.Base.Resp> {
const url = `${PassportUrl}Verify`;
const header = await getReqHeader();
const data: TGApp.Plugins.Hutao.Account.ResetPwdCodeParam = {
UserName: rsaEncrypt(username),
IsCancelRegistration: false,
IsResetPassword: true,
IsResetUserName: false,
IsResetUserNameNew: false,
};
const resp = await TGHttp<TGApp.Plugins.Hutao.Base.Resp>(url, {
method: "POST",
headers: header,
body: JSON.stringify(data),
});
console.log(resp);
return resp;
}
/**
* 重置密码
* @since Beta v0.9.1
* @param username - 用户
* @param code - 验证码
* @param pwd - 密码
* @returns 重置密码返回
*/
export async function resetPwd(
username: string,
code: string,
pwd: string,
): Promise<TGApp.Plugins.Hutao.Base.Resp> {
const url = `${PassportUrl}ResetPassword`;
const header = await getReqHeader();
const data: TGApp.Plugins.Hutao.Account.ResetPwdParams = {
UserName: rsaEncrypt(username),
Password: rsaEncrypt(pwd),
VerifyCode: rsaEncrypt(code),
IsCancelRegistration: false,
IsResetPassword: true,
IsResetUserName: false,
IsResetUserNameNew: false,
};
const resp = await TGHttp<TGApp.Plugins.Hutao.Base.Resp>(url, {
method: "POST",
headers: header,
body: JSON.stringify(data),
});
console.log(resp);
return resp;
}

View File

@@ -98,4 +98,82 @@ declare namespace TGApp.Plugins.Hutao.Account {
/** 用户名 */
UserName: string;
};
/**
* Verify接口请求参数
* @since Beta v0.9.1
* @remarks
* - 同一邮箱同一类型验证码在 60 秒内只能申请一次,请在客户端进行节流处理。
* - 若需要重置用户名,请分别提交旧邮箱与新邮箱两次请求以获取成对验证码。
*/
type VerifyParams =
| ResetPwdCodeParam
| ResetUserNameCodeParam
| ResetUserNameNewCodeParam
| CancelRegCodeParam;
/**
* Verify接口Flag值
* @since Beta v0.9.1
*/
type VerifyFlags =
| "IsResetPassword"
| "IsResetUserName"
| "IsResetUserNameNew"
| "IsCancelRegistration";
/**
* Verify Flag 生成
* @since Beta v0.9.1
*/
type VerifyFlagGen<T extends VerifyFlags> = {
[K in VerifyFlags]: K extends T ? true : false;
};
/**
* 获取重设密码验证码参数
* @since Beta v0.9.1
*/
type ResetPwdCodeParam = {
/** 用户名 */
UserName: string;
} & VerifyFlagGen<"IsResetPassword">;
/**
* 重设密码参数
* @since Beta v0.9.1
*/
type ResetPwdParams = ResetPwdCodeParam & {
/** 密码 */
Password: string;
/** 验证码 */
VerifyCode: string;
};
/**
* 获取重设用户名验证码参数
* @since Beta v0.9.1
*/
type ResetUserNameCodeParam = {
/** 用户名 */
UserName: string;
} & VerifyFlagGen<"IsResetUserName">;
/**
* 获取重设用户名-二次验证码参数
* @since Beta v0.9.1
*/
type ResetUserNameNewCodeParam = {
/** 用户名 */
UserName: string;
} & VerifyFlagGen<"IsResetUserNameNew">;
/**
* 获取取消注册验证码参数
* @since Beta v0.9.1
*/
type CancelRegCodeParam = {
/** 用户名 */
UserName: string;
} & VerifyFlagGen<"IsCancelRegistration">;
}