feat(login): kg/tx 登录态自动续期(移植 lx-music-api-server 方案)
- kg: login_by_token 续期(AES-256-CBC + RSA 裸加密,参考其 refresh/kg.py),新 token 回写 data/auth.json - tx: 新增 sdk/auth/tx.ts —— cookie 解析、VIP 检测(vip_login_base)、 music.login.LoginServer 续期(走既有 musicu.fcg 未签名通道,最佳努力) - 调度:启动 10s 后首刷 + 每 24h 一次(对齐参考项目 86400s + next_run_time=now) - /login/tx 支持可选 App 抓包凭据(openId/accessToken/refreshToken/refreshKey) - 新增 POST /login/refresh 手动续期;/login/status 增补 tx 字段与更新时间 - 补充 /login/tx 文档行与 smoke 测试
This commit is contained in:
1 parent
9d7cb6f39a
commit
aca7928019
8 files changed
+300
-9
No files matched your search
@@ -30,6 +30,7 @@ import musicSdk from '../sdk/index.ts'
|
||||
import { ApiError } from './http/api-error.ts'
|
||||
import { musicRoutes } from './routes.ts'
|
||||
import { loginRoutes } from './routes-login.ts'
|
||||
import { startRefreshScheduler } from './refresh.ts'
|
||||
import { COMPONENT_SCHEMAS } from './openapi/components.ts'
|
||||
import { redocHtml } from './openapi/ui.ts'
|
||||
|
||||
@@ -184,6 +185,9 @@ fastify.get('/', {
|
||||
fastify.register(musicRoutes)
|
||||
fastify.register(loginRoutes)
|
||||
|
||||
// 登录态自动续期(onClose 钩子需在 listen 前注册,故这里而非 startServer 内启动)
|
||||
startRefreshScheduler(fastify)
|
||||
|
||||
export const startServer = async(port = PORT) => {
|
||||
await fastify.listen({ port: Number(port), host: '0.0.0.0' })
|
||||
console.log(`音乐服务器已启动: http://localhost:${port}`)
|
||||
|
||||
Reference in new issue
Block a user