{"record":{"id":"48f869f696b07a2a","repo":"jackwener/OpenCLI","slug":"probe-detail-48f869","errorCode":null,"errorMessage":"${probe.detail}","messagePattern":"\\$\\{probe\\.detail\\}","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/chaoxing/auth.js","lineNumber":36,"sourceCode":"        return { kind: 'auth', detail: 'Chaoxing i.chaoxing.com redirected to passport2 login' };\n      }\n      const userIdCookie = (document.cookie.split('; ').find(c => /^(_uid|UID)=/.test(c)) || '').split('=')[1] || '';\n      let userName = '';\n      const unameCookie = (document.cookie.split('; ').find(c => /^uname=/.test(c)) || '').split('=')[1] || '';\n      if (unameCookie) {\n        try { userName = decodeURIComponent(unameCookie); } catch { userName = unameCookie; }\n      }\n      if (!userName) {\n        const el = document.querySelector('.userTitle, .myInfo, .user-name, [class*=userName]');\n        userName = (el?.innerText || '').trim();\n      }\n      if (!userIdCookie && !userName) {\n        return { kind: 'auth', detail: 'Chaoxing i.chaoxing.com no user identity surface — anonymous' };\n      }\n      return { ok: true, user_id: userIdCookie, name: userName };\n    })()\n  `);\n  if (probe?.kind === 'auth') throw new AuthRequiredError('chaoxing.com', probe.detail);\n  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Chaoxing probe: ${JSON.stringify(probe)}`);\n  return { user_id: probe.user_id, name: probe.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'chaoxing',\n  domain: 'chaoxing.com',\n  loginUrl: 'https://passport2.chaoxing.com/login?fid=&newversion=true&refer=https%3A%2F%2Fi.chaoxing.com',\n  columns: ['user_id', 'name'],\n  quickCheck: hasChaoxingSessionCookie,\n  verify: verifyChaoxingIdentity,\n  poll: async (page) => {\n    if (!await hasChaoxingSessionCookie(page)) {\n      throw new AuthRequiredError('chaoxing.com', 'Waiting for Chaoxing session cookies');\n    }\n    return verifyChaoxingIdentity(page);\n  },\n});","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chaoxing/auth.js#L18-L54","documentation":"After loading i.chaoxing.com, verifyChaoxingIdentity runs an in-page probe that classifies the result. If the probe returns kind:'auth' (no user identity surface — page is effectively anonymous, e.g. redirected toward passport2 login), the library throws AuthRequiredError with the probe's own detail message. Cookies existed but the site does not recognize the session.","triggerScenarios":"Cookies pass the local check but the server session is dead (expired server-side), so i.chaoxing.com renders anonymous/login state and the probe reports no user identity.","commonSituations":"Server-side session expiry while stale client cookies remain; account logged out from another device; ip/risk control invalidating the session.","solutions":["Re-login via the chaoxing login command and retry identity verification","Delete stale cookies and perform a fresh full login","Check for a redirect to passport2.chaoxing.com/login — that confirms the session is dead","If it persists, the account may be under risk control; log in manually in the automation browser once"],"exampleFix":"// before\nif (probe?.kind === 'auth') throw new AuthRequiredError('chaoxing.com', probe.detail);\n// after\nif (probe?.kind === 'auth') {\n  await login(page);            // refresh dead session\n  return verifyChaoxingIdentity(page); // retry once\n}","handlingStrategy":"try-catch","validationCode":"// cookie presence alone is insufficient; probe after login\nawait page.goto('https://i.chaoxing.com/');\nif (/passport2\\.chaoxing\\.com\\/login/.test(page.url())) await chaoxingLogin(page);","typeGuard":"function probeOk(p) { return !!p && (p.kind === 'auth' || p.ok === true); }","tryCatchPattern":"try { const id = await whoami(page); }\ncatch (e) { if (e instanceof AuthRequiredError) { await login(page); return whoami(page); } throw e; }","preventionTips":["Check page.url() for a login redirect before probing","Re-login whenever the probe reports anonymous — stale cookies don't imply a live session","Handle multi-device logout: sessions die server-side","Automate one re-login + retry on AuthRequiredError"],"tags":["chaoxing","auth","session-expired","probe"],"backgroundTag":"auth-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}