fix(api): 删除多余字符修复代码格式问题

- 移除文件末尾多余的不可见字符
- 确保代码结尾整洁无冗余
- 防止潜在的语法或解析错误

fix(itunes): 修复代理参数传递错误

- 移除了未使用的 re 模块导入
- 将代理调用中的参数由 account_name 改为 account
- 优化异常追踪导入的顺序
- 确保请求代理使用正确的账户标识参数

fix(itunes): 修复登录响应返回及代理参数错误

- 修正了Itunes登录失败时返回的ItunesLoginResponse格式
- 修复了代理服务调用时传入的账户名称参数错误
- 保证返回对象包含serverId、response和原始日志信息
- 使用正确的账户字段以匹配代理服务要求

fix(itunes): 添加登录相关请求和响应日志

- 在请求数据生成处添加日志记录 POST 数据内容
- 在登录响应处理处添加日志记录返回的响应文本内容

fix(itunes): 添加日志记录以跟踪 GUID 和账户信息

- 在 _get_post_data 方法中增加日志输出
- 记录传入的 GUID 和 Apple 账户信息
- 便于调试和问题排查

refactor(itunes): 优化AES密码解密逻辑并添加解密测试

- 将密码解密过程从内联字符串中抽离为单独变量,提升代码可读性
- 在测试模块中添加decrypt_with_aes函数的测试用例
- 优化测试导入模块,确保解密函数正常导入使用
This commit is contained in:
danial
2025-11-14 17:59:59 +08:00
parent 14c70b1934
commit 0e8a6ffa4b
3 changed files with 18 additions and 10 deletions

View File

@@ -76,14 +76,14 @@ class AppleClient:
return ".".join(segments)
def _get_post_data(self, guid: str, account: AppleAccountModel):
logger.info(f"GUID: {guid} {account}")
post_data = f"""<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>appleId</key><string>{account.account}</string><key>attempt</key><string>1</string><key>guid</key><string>{guid}</string><key>password</key><string>{decrypt_with_aes(
account.password,
AESKey.load_from_base64(
"P0x6Gy6dXIpPbhE7PHxaHbfZHhsbT2qNPlx3qbHTP1o"
),
AESKey.load_from_base64("nywao1XkDXeYwbPeWh+SxA=="),
)}</string><key>rmp</key><string>0</string><key>createSession</key><string>true</string><key>why</key><string>purchase</string></dict></plist>"""
password = decrypt_with_aes(
account.password,
AESKey.load_from_base64(
"P0x6Gy6dXIpPbhE7PHxaHbfZHhsbT2qNPlx3qbHTP1o"
),
AESKey.load_from_base64("nywao1XkDXeYwbPeWh+SxA=="),
)
post_data = f"""<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>appleId</key><string>{account.account}</string><key>attempt</key><string>1</string><key>guid</key><string>{guid}</string><key>password</key><string>{password}</string><key>rmp</key><string>0</string><key>createSession</key><string>true</string><key>why</key><string>purchase</string></dict></plist>"""
logger.info(f"POST DATA: {post_data}")
return post_data

View File

@@ -207,4 +207,3 @@ class SixClient:
response.Data.guid = parse.unquote_plus(response.Data.guid)
response.Data.post = parse.unquote_plus(response.Data.post)
return response
ƒ

View File

@@ -1,6 +1,6 @@
from unittest import TestCase
from src.utils.crypto import encrypt_with_aes, AESKey
from src.utils.crypto import encrypt_with_aes, AESKey, decrypt_with_aes
class Test(TestCase):
@@ -11,3 +11,12 @@ class Test(TestCase):
AESKey.load_from_base64("nywao1XkDXeYwbPeWh+SxA=="),
)
print(result)
def test_decrypt_with_aes(self):
result = decrypt_with_aes(
"uDdGDAizNq7EuF5TH163PA==",
AESKey.load_from_base64(
"P0x6Gy6dXIpPbhE7PHxaHbfZHhsbT2qNPlx3qbHTP1o="
),
AESKey.load_from_base64("nywao1XkDXeYwbPeWh+SxA=="),
)
print(result)