ddce8b3d8d
Move the Qwen page-state probe, session detection, and silent probe helpers out of account-binder into apps/desktop-client/src/main/adapters/qwen, mirroring the Kimi adapter layout. Generic AI auth no longer special-cases qwen since the platform now owns its own credential rules. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
113 lines
3.7 KiB
TypeScript
113 lines
3.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
genericAIPageLooksAuthenticated,
|
|
isLikelyGenericAICredentialName,
|
|
isLikelyPlatformAICredentialCookie,
|
|
} from './generic-ai-auth'
|
|
|
|
describe('generic ai auth detection', () => {
|
|
it('treats deepseek home as authenticated when credential storage exists', () => {
|
|
expect(
|
|
genericAIPageLooksAuthenticated('https://chat.deepseek.com/', {
|
|
displayName: null,
|
|
avatarUrl: null,
|
|
fingerprint: 'local:userToken=masked',
|
|
credentialFingerprint: 'local:userToken=masked',
|
|
currentPath: '/',
|
|
strongAuthSignalCount: 0,
|
|
loginSignalCount: 0,
|
|
loggedOutSignalCount: 0,
|
|
challengeSignalCount: 0,
|
|
}),
|
|
).toBe(true)
|
|
})
|
|
|
|
it('does not treat anonymous conversation URLs as authenticated', () => {
|
|
expect(
|
|
genericAIPageLooksAuthenticated('https://www.doubao.com/chat/', {
|
|
displayName: null,
|
|
avatarUrl: null,
|
|
fingerprint: 'https://www.doubao.com/chat/|Doubao',
|
|
credentialFingerprint: null,
|
|
currentPath: '/chat/',
|
|
strongAuthSignalCount: 0,
|
|
loginSignalCount: 0,
|
|
loggedOutSignalCount: 0,
|
|
challengeSignalCount: 0,
|
|
}),
|
|
).toBe(false)
|
|
})
|
|
|
|
it('keeps anonymous telemetry cookies out of generic credential matching', () => {
|
|
expect(isLikelyGenericAICredentialName('hook_slardar_session_id')).toBe(false)
|
|
expect(isLikelyGenericAICredentialName('ttwid')).toBe(false)
|
|
expect(isLikelyGenericAICredentialName('XSRF-TOKEN')).toBe(false)
|
|
expect(isLikelyGenericAICredentialName('passport_auth_token')).toBe(true)
|
|
})
|
|
|
|
it('keeps platform-specific Qwen cookies out of generic credential matching', () => {
|
|
expect(
|
|
isLikelyPlatformAICredentialCookie('qwen', 'tongyi_sso_ticket', 'anonymous-qwen-cookie', {
|
|
displayName: '通义千问账号',
|
|
avatarUrl: null,
|
|
fingerprint: null,
|
|
credentialFingerprint: null,
|
|
currentPath: '/',
|
|
strongAuthSignalCount: 1,
|
|
loginSignalCount: 0,
|
|
loggedOutSignalCount: 0,
|
|
challengeSignalCount: 0,
|
|
}),
|
|
).toBe(false)
|
|
})
|
|
|
|
it('allows generic credential cookies for platforms without isolated auth rules', () => {
|
|
expect(
|
|
isLikelyPlatformAICredentialCookie('deepseek', 'userToken', 'real-token-value', {
|
|
displayName: null,
|
|
avatarUrl: null,
|
|
fingerprint: null,
|
|
credentialFingerprint: null,
|
|
currentPath: '/',
|
|
strongAuthSignalCount: 0,
|
|
loginSignalCount: 0,
|
|
loggedOutSignalCount: 0,
|
|
challengeSignalCount: 0,
|
|
}),
|
|
).toBe(true)
|
|
})
|
|
|
|
it('does not run Kimi through generic credential cookies', () => {
|
|
expect(
|
|
isLikelyPlatformAICredentialCookie('kimi', 'kimi-auth', 'anonymous-kimi-cookie', {
|
|
displayName: '阿白',
|
|
avatarUrl: 'https://avatar.moonshot.cn/avatar/demo.jpeg',
|
|
fingerprint: null,
|
|
credentialFingerprint: 'local:access_token=real-token',
|
|
currentPath: '/',
|
|
strongAuthSignalCount: 3,
|
|
loginSignalCount: 0,
|
|
loggedOutSignalCount: 0,
|
|
challengeSignalCount: 0,
|
|
}),
|
|
).toBe(false)
|
|
})
|
|
|
|
it('does not run Doubao through generic credential cookies', () => {
|
|
expect(
|
|
isLikelyPlatformAICredentialCookie('doubao', 'passport_auth_token', 'real-auth-token', {
|
|
displayName: '豆包用户',
|
|
avatarUrl: 'https://p3-passport.byteacctimg.com/img/user-avatar/demo.image',
|
|
fingerprint: null,
|
|
credentialFingerprint: null,
|
|
currentPath: '/chat/',
|
|
strongAuthSignalCount: 3,
|
|
loginSignalCount: 0,
|
|
loggedOutSignalCount: 0,
|
|
challengeSignalCount: 0,
|
|
}),
|
|
).toBe(false)
|
|
})
|
|
})
|