feat(login): wy cookie 绑定与 qs 短信/sessionid 登录
wy 新增 POST /login/wy(cookie 须含 MUSIC_U,account/get 实测校验、失效 401,与 kg 假 token 同款语义);qs 新增 POST /login/qs/sms、/login/qs/sms/login (官方 PC 客户端 WebInterfaceSdk 同款 send_code/sms_login,失败映射官方文案, 2046 需去汽水 App 完成安全验证)与 POST /login/qs(sessionid 手动绑定, user_info 端点恒 16 无权限、不做上游校验)。smoke 补 6 项登录校验用例。
This commit is contained in:
1 parent
6b05fde64b
commit
76fb812a50
4 files changed
+246
-2
No files matched your search
@@ -113,6 +113,28 @@ export const cellphoneLogin = async({ phone, password, captcha, countrycode = '8
|
||||
return profile
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动绑定 cookie(从已登录的 music.163.com 浏览器请求头复制,须含 MUSIC_U)。
|
||||
* 绑定前用 account/get 实测校验,失效直接报 401,与 kg 绑定 token 同款语义。
|
||||
*/
|
||||
export const loginByCookie = async(cookieInput: string) => {
|
||||
const cookie = String(cookieInput || '').trim()
|
||||
const musicU = /MUSIC_U=([^;\s]+)/.exec(cookie)?.[1]
|
||||
if (!musicU) throw Object.assign(new Error('cookie 需包含 MUSIC_U 字段'), { status: 422 })
|
||||
const { body } = await requestWeapi('/api/w/nuser/account/get', {}, cookie)
|
||||
if (!body?.account?.id) {
|
||||
throw Object.assign(new Error('cookie 无效或已过期(MUSIC_U 校验未通过)'), { status: 401 })
|
||||
}
|
||||
const profile = {
|
||||
userid: body.account.id,
|
||||
nickname: body.profile?.nickname ?? null,
|
||||
avatar: body.profile?.avatarUrl ?? null,
|
||||
vipType: body.profile?.vipType ?? null,
|
||||
}
|
||||
setCredentials('wy', { cookie, musicU, ...profile })
|
||||
return profile
|
||||
}
|
||||
|
||||
/** 当前账号资料(未登录返回 null) */
|
||||
export const status = async() => {
|
||||
if (!getWyCookie()) return null
|
||||
|
||||
Reference in new issue
Block a user