jackwener / jackwener/OpenCLI

[Tracking] 待完成的 login/whoami 站点(社区可认领)

Open
#1,876 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
29.3k
Forks
2.9k
Avg merge
15h 36m
Merged PRs (30d)
70

Description

## 背景

`opencli login` / `opencli whoami` 框架(`clis/_shared/site-auth.js`,见 #1852)已在 **#1866** 覆盖 **60 个站点**。本 Issue 跟踪**还没做完**的登录态站点,欢迎社区一起补。

### Adapter 契约(写新站点请遵守)

每个 `clis//auth.js` 调用 `registerSiteAuthCommands({ site, domain, loginUrl, columns, verify, poll })`:

- **`verify(page)`** 返回 **plain object**(不是数组),框架自动加 `logged_in` + `site` 列;**不要**在 `columns` 或返回里放 `login` 字段。
- **两段式探测**:`poll` 做便宜的「是否登录」判断,`verify` 做真实身份提取。
- **typed error**:未登录 → `AuthRequiredError`;布局漂移/HTTP/解析失败 → `CommandExecutionError`。**禁止** silent `return []` / sentinel row / `Math.min` 钳值。
- **cookie 一律用 CDP `page.getCookies({url})`**(能看 httpOnly);**不要在 `page.evaluate` 里用 `document.cookie` 读 httpOnly cookie**(看不到,会和 gate 不一致)。
- **`poll` 的 gate 必须是「仅登录态才有」的信号**(logged-in-only cookie 或 no-navigation 的 API/DOM 探测)。否则 login 流程每 2s 会把用户从登录页导航走。
- discriminated-union 探测:成功用 `{ ok: true, ...columns }`(`ok` 已被 silent-column-drop audit 豁免),失败用 `{ kind: 'auth'|'http'|'exception', detail }`。
- **🔒 硬约束:`whoami` 只输出可安全展示的身份锚点** —— public handle / username / stable user_id / user_type。**不输出** email、手机号、真实姓名、cookie / token / session value。默认「探到了也不返回」,除非能证明是公开 profile 字段才输出(不能证明就不输出)。尤其 **cookie / token 值只用于判断是否登录,绝不作为返回列**(输出会话凭证 = 泄漏 session)。
- 提交前跑:`npm run build && npm test && npm run check:typed-error-lint && npm run check:silent-column-drop`(后两个必须 `new=0`)。

---

## TODO:待完成的登录态站点

> 这些站我在调研时处于**未登录态**,whoami 的 identity endpoint/DOM 探不准,没有瞎猜落码(避免「verify 假过、数据是错的」)。需要在**登录态**下确认 whoami 探测后补上。括号内是已探到的线索。

- [ ] **nowcoder(牛客)** — `domain: nowcoder.com`,gateway `gw-c.nowcoder.com`,登录 cookie 疑为 `t`。`/api/sparta/message/pc/unread/detail` 是登录态接口(见 `clis/nowcoder/notifications.js`)。whoami endpoint 待定(`/api/sparta/user/profile/info` 匿名返 400 `code:1`,需登录态确认字段)。
- [ ] **jimeng(即梦 / jimeng.jianying.com)** — ByteDance 系,`/mweb/v1/...?aid=513695`(见 `clis/jimeng/new.js`),cookie 疑为 `sessionid`。user-info endpoint 待定。
- [ ] **maimai(脉脉)** — `domain: maimai.cn`,cookie `csrftoken`(见 `clis/maimai/search-talents.js`)。`/api/account/v1/get_user_info` 匿名返 200 非 JSON,需登录态确认正确 whoami 接口与字段。
- [ ] **jike(即刻 / web.okjike.com)** — 匿名 redirect 到 `/login`;auth 走 localStorage `x-jike-access-token`(非 cookie),API 在 `web-api.okjike.com`。whoami endpoint 待定(graphql 路径需登录态确认)。

## 需要框架改造(不是单站能解决)

- [ ] **atlassian(jira / confluence)** — workspace-scoped `*.atlassian.net`,每个 workspace 域名不同。需要框架先支持 `--host` 参数 + wildcard domain + `login_url_template`,才能做通用 login/whoami。

## 已知受限 / 暂缓

- [ ] **weixin(微信网页版)** — 网页端登录大面积停用,多数账号无法 web 登录,价值低。
- [ ] **youdao(有道)/ mubu(幕布)** — 需要登录态 live retest 才能定 cookie SoT 与 whoami。

---

## 不需要做(公开读,无需登录)

这些站的现有 adapter 是**公开 API / 搜索**,加 login/whoami 无意义,**请勿浪费精力**:
`binance`、`bluesky`、`zlibrary`、`smzdm`、`51job`、`indeed`、`tieba`、`spotify`、`steam`,以及所有搜索引擎 / 包仓库 / 学术 / 公开数据 / 新闻类站点。

---

参考实现:`clis/v2ex/auth.js`(DOM + httpOnly cookie gate)、`clis/gitee/auth.js`(HTTP endpoint + no-nav poll)、`clis/deepseek/auth.js`(localStorage Bearer token)。

Contributor guide

Open the contributing guide

Research direction

Start by reading clis/_shared/site-auth.js and the referenced adapters, especially clis/v2ex/auth.js, clis/gitee/auth.js, and clis/deepseek/auth.js. Choose one bounded site from the TODO list, confirm its authenticated identity endpoint or DOM behavior, then run the listed build, test, typed-error-lint, and silent-column-drop checks. Done means the adapter follows the contract and all checks pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, playwright
Domain
api, authentication, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.