@dreamor/atlas-cli 0.7.4 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,10 +61,25 @@ export async function login(_port) {
61
61
  log('请在浏览器中完成 SSO 登录...');
62
62
  log('登录成功后页面会自动跳转,CLI 会自动捕获 cookies');
63
63
  await page.goto(`https://${BANMA_HOST}/`, { waitUntil: 'domcontentloaded', timeout: 60000 });
64
- // 等待 access_token cookie 出现(最多 120s),比脆弱的 url 判断 + 固定 timeout 更可靠
65
- await page.waitForFunction(() => document.cookie.includes('access_token'), { timeout: 120_000 });
64
+ // 等待 access_token cookie 出现(最多 120s)。
65
+ // 注意 access_token 是 HttpOnly cookie,不能用 document.cookie 检测,
66
+ // 必须走 page.context().cookies() 才能读到。
67
+ const MAX_WAIT = 120_000;
68
+ const POLL_INTERVAL = 500;
69
+ let foundToken = false;
70
+ for (let elapsed = 0; elapsed < MAX_WAIT; elapsed += POLL_INTERVAL) {
71
+ const allCookies = await page.context().cookies();
72
+ if (allCookies.some((c) => c.name === 'access_token' && c.value)) {
73
+ foundToken = true;
74
+ break;
75
+ }
76
+ await page.waitForTimeout(POLL_INTERVAL);
77
+ }
78
+ if (!foundToken) {
79
+ log('SSO 登录检测超时。如果您已完成登录,请按 Ctrl+C 重试或确认账号权限。');
80
+ }
66
81
  // 额外等待确保残留 cookie 写入完毕
67
- await page.waitForTimeout(1000);
82
+ await page.waitForTimeout(500);
68
83
  // Extract cookies — 精确白名单,避免整域 cookies 落盘
69
84
  const cookies = await page.context().cookies();
70
85
  const atlasCookies = cookies
@@ -1 +1 @@
1
- export const ATLAS_VERSION = '0.7.4';
1
+ export const ATLAS_VERSION = '0.7.5';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamor/atlas-cli",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "Atlas CLI - 斑马云图人力基线管理工具",
5
5
  "type": "module",
6
6
  "bin": {