收敛半自动平台为登录获取 CK 流程
移除角色绑定对客户页、状态展示和完成门禁的阻塞;虎牙与微博统一保存并直接导出 CK;同步精简客服工作台、配置项和权威文档。
This commit is contained in:
@@ -370,12 +370,6 @@ export async function createSemiAutoMock(
|
||||
: connectorMode === 'mock'
|
||||
? 'Mock 登录:点击获取二维码后,页面轮询两次会自动模拟登录成功。'
|
||||
: '真实登录:点击获取二维码后,请使用虎牙 App 扫码并在手机上确认登录。',
|
||||
bindingInstructions:
|
||||
platform === 'weibo'
|
||||
? '微博登录成功即完成授权,无需再绑定游戏角色。'
|
||||
: connectorMode === 'mock'
|
||||
? 'Mock 绑定:页面轮询两次后会自动识别角色,点击确认即可。'
|
||||
: '真实绑定:扫码后等待 Connector 识别角色,核对账号和区服后点击确认绑定。',
|
||||
...(platform === 'weibo' ? { loginMethods: ['sms', 'qr'] } : {}),
|
||||
browserTargets: [
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
consumeMockBrowserTicket,
|
||||
createMockBrowserTicket,
|
||||
createMockLoginSession,
|
||||
exportMockSessionCredential,
|
||||
getMockBinding,
|
||||
getMockLoginSession,
|
||||
resetMockSessions,
|
||||
@@ -31,6 +32,9 @@ test('Mock Connector 可按轮询自动完成登录、绑定和一次性票据
|
||||
assert.equal(authenticated.status, 'authenticated')
|
||||
assert.equal(authenticated.hasCredential, true)
|
||||
assert.ok(authenticated.huyaUid)
|
||||
const credential = exportMockSessionCredential(created.sessionId)
|
||||
assert.equal(credential.platformUid, authenticated.huyaUid)
|
||||
assert.ok(credential.cookies.length >= 1)
|
||||
|
||||
const binding = startMockBinding(created.sessionId)
|
||||
assert.equal(binding.status, 'qr_pending')
|
||||
@@ -65,6 +69,12 @@ test('Mock Connector 支持控制状态、撤销会话和重置', () => {
|
||||
assert.equal(authenticated.status, 'authenticated')
|
||||
assert.equal(authenticated.hasCredential, true)
|
||||
|
||||
const ticket = createMockBrowserTicket({
|
||||
sessionId: created.sessionId,
|
||||
targetUrl: 'https://www.huya.com/no-binding',
|
||||
})
|
||||
assert.equal(consumeMockBrowserTicket(ticket.ticket).targetUrl, 'https://www.huya.com/no-binding')
|
||||
|
||||
const confirmed = setMockBindingStatus(created.sessionId, 'confirmed')
|
||||
assert.equal(confirmed.status, 'confirmed')
|
||||
assert.ok(confirmed.bindGameRole)
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
ConnectorInjectionPayload,
|
||||
ConnectorLoginSession,
|
||||
} from '../semi-auto/huya-connector-client.js'
|
||||
import type { HuyaStoredCredential } from '../semi-auto/huya-native/huya-native-connector.js'
|
||||
import { createHttpError } from '../../utils/http.js'
|
||||
|
||||
const LOGIN_QR_TTL_MS = 5 * 60 * 1000
|
||||
@@ -203,6 +204,42 @@ export function getMockLoginSession(sessionIdInput: unknown): ConnectorLoginSess
|
||||
return loginView(session)
|
||||
}
|
||||
|
||||
export function exportMockSessionCredential(sessionIdInput: unknown): HuyaStoredCredential {
|
||||
const session = requireSession(sessionIdInput)
|
||||
if (session.loginStatus !== 'authenticated' || !session.hasCredential) {
|
||||
throw createHttpError('Mock 登录尚未完成,不能导出 CK', {
|
||||
statusCode: 409,
|
||||
errorCode: 'mock_semi_auto_credential_not_ready',
|
||||
})
|
||||
}
|
||||
return {
|
||||
platformUid: session.huyaUid,
|
||||
nickname: session.nickname,
|
||||
cookies: [
|
||||
{
|
||||
name: 'mock_huya_uid',
|
||||
value: session.huyaUid,
|
||||
domain: '.huya.com',
|
||||
path: '/',
|
||||
secure: true,
|
||||
httpOnly: false,
|
||||
hostOnly: false,
|
||||
expiresAt: null,
|
||||
},
|
||||
{
|
||||
name: 'mock_huya_session',
|
||||
value: session.sessionId,
|
||||
domain: '.huya.com',
|
||||
path: '/',
|
||||
secure: true,
|
||||
httpOnly: true,
|
||||
hostOnly: false,
|
||||
expiresAt: null,
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
export function startMockBinding(sessionIdInput: unknown): ConnectorBindingSession {
|
||||
const session = requireSession(sessionIdInput)
|
||||
if (session.loginStatus !== 'authenticated') {
|
||||
@@ -259,10 +296,10 @@ export function createMockBrowserTicket(input: {
|
||||
targetUrl?: unknown
|
||||
}): ConnectorBrowserTicket {
|
||||
const session = requireSession(input.sessionId)
|
||||
if (session.bindingStatus !== 'confirmed') {
|
||||
throw createHttpError('Mock 角色尚未绑定,不能生成浏览器票据', {
|
||||
if (session.loginStatus !== 'authenticated' || !session.hasCredential) {
|
||||
throw createHttpError('Mock 登录尚未完成,不能生成浏览器票据', {
|
||||
statusCode: 409,
|
||||
errorCode: 'mock_semi_auto_binding_required',
|
||||
errorCode: 'mock_semi_auto_login_required',
|
||||
})
|
||||
}
|
||||
const ticket = `mock-ticket-${crypto.randomUUID()}`
|
||||
|
||||
Reference in New Issue
Block a user