todo: fix UserData decryption

This commit is contained in:
mokurin000
2025-07-31 01:13:00 +08:00
parent c4860b812b
commit 1943b5b1f6
10 changed files with 216 additions and 23 deletions

View File

@@ -14,6 +14,7 @@ use nyquest::{
header::{ACCEPT_ENCODING, CONTENT_ENCODING, EXPECT, USER_AGENT},
};
use serde::{Deserialize, Serialize};
use spdlog::debug;
pub trait MaiVersion {
const AES_KEY: &[u8; 32];
@@ -24,7 +25,7 @@ pub trait MaiVersion {
pub trait MaiVersionExt: MaiVersion {
fn encode(data: impl AsRef<[u8]>) -> Result<Vec<u8>, ApiError>;
fn decode(data: impl AsMut<[u8]>) -> Result<Vec<u8>, ApiError>;
fn decode(data: impl AsRef<[u8]>) -> Result<Vec<u8>, ApiError>;
fn api_hash(api: APIMethod) -> String {
let api_name: &str = api.into();
@@ -78,6 +79,9 @@ pub trait MaiVersionExt: MaiVersion {
.await
.map_err(|_| ApiError::JoinError)??;
let data = client.request(req).await?.bytes().await?;
debug!("received: {data:?}");
let decoded = spawn_blocking(move || Self::decode(data))
.await
.map_err(|_| ApiError::JoinError)??;