@dreamor/atlas-cli 0.7.5 → 0.7.7

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.
@@ -7,7 +7,6 @@ const _require = createRequire(import.meta.url);
7
7
  const BANMA_HOST = 'banma-yuntu.alibaba-inc.com';
8
8
  // 白名单:只保存 getBanmaIdentity 真正需要的 cookies,避免整域 cookies 落盘
9
9
  const WANT_COOKIES = new Set(['access_token', 'buc_username', 'buc_userinfo']);
10
- const EMP_ID_NAMES = new Set(['emp_id', 'empId', 'employeeId']);
11
10
  /**
12
11
  * 动态加载 playwright。顶层静态 import 会让单文件 bundle 在未安装 playwright 的
13
12
  * 环境下无法启动(连 --version 都 require 失败),故改为运行时动态 import + try/catch
@@ -99,10 +98,20 @@ export async function loginStatus() {
99
98
  try {
100
99
  const daemonCookies = await fetchCookiesFromDaemon();
101
100
  if (daemonCookies && daemonCookies.length > 0) {
102
- const empIdCookie = daemonCookies.find((c) => EMP_ID_NAMES.has(c.name));
101
+ const userinfoCookie = daemonCookies.find((c) => c.name === 'buc_userinfo');
102
+ let displayName = 'via-daemon';
103
+ if (userinfoCookie) {
104
+ try {
105
+ const decoded = JSON.parse(Buffer.from(userinfoCookie.value, 'base64').toString('utf-8'));
106
+ displayName = decoded.name || decoded.account || `工号 ${decoded.emp_id}`;
107
+ }
108
+ catch {
109
+ // fallback
110
+ }
111
+ }
103
112
  return {
104
113
  loggedIn: true,
105
- account: empIdCookie?.value ?? 'via-daemon',
114
+ account: displayName,
106
115
  mode: 'daemon',
107
116
  };
108
117
  }
@@ -113,10 +122,25 @@ export async function loginStatus() {
113
122
  // Check local cookies
114
123
  const cookies = await readCookies();
115
124
  if (cookies && cookies.length > 0) {
116
- const empIdCookie = cookies.find((c) => EMP_ID_NAMES.has(c.name));
125
+ const userinfoCookie = cookies.find((c) => c.name === 'buc_userinfo');
126
+ let displayName = '已登录';
127
+ if (userinfoCookie) {
128
+ try {
129
+ const decoded = JSON.parse(Buffer.from(userinfoCookie.value, 'base64').toString('utf-8'));
130
+ displayName = decoded.name || decoded.account || `工号 ${decoded.emp_id}`;
131
+ }
132
+ catch {
133
+ // fallback below
134
+ }
135
+ }
136
+ if (displayName === '已登录') {
137
+ const bucUser = cookies.find((c) => c.name === 'buc_username');
138
+ if (bucUser)
139
+ displayName = bucUser.value;
140
+ }
117
141
  return {
118
142
  loggedIn: true,
119
- account: empIdCookie?.value ?? 'cookies-present',
143
+ account: displayName,
120
144
  mode: 'local',
121
145
  };
122
146
  }
@@ -1 +1 @@
1
- export const ATLAS_VERSION = '0.7.5';
1
+ export const ATLAS_VERSION = '0.7.7';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamor/atlas-cli",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "description": "Atlas CLI - 斑马云图人力基线管理工具",
5
5
  "type": "module",
6
6
  "bin": {