feat(auth): add login/whoami for nowcoder, jike, maimai, jimeng#1878
Open
Benjamin-eecs wants to merge 1 commit into
Open
feat(auth): add login/whoami for nowcoder, jike, maimai, jimeng#1878Benjamin-eecs wants to merge 1 commit into
Benjamin-eecs wants to merge 1 commit into
Conversation
7 tasks
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds browser-based authentication helpers and CLI manifest entries to support login and whoami flows for several sites (Jike, Jimeng, Maimai, Nowcoder).
Changes:
- Introduces new
auth.jsmodules for nowcoder/maimai/jimeng/jike that probe current identity via page evaluation + site APIs. - Registers new
loginandwhoamicommands for these sites incli-manifest.json. - Adds lightweight polling/verification logic to detect completion of interactive logins.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| clis/nowcoder/auth.js | Adds Nowcoder session detection + identity verification and registers site auth commands. |
| clis/maimai/auth.js | Adds Maimai identity probe by parsing server-rendered inline script and registers site auth commands. |
| clis/jimeng/auth.js | Adds Jimeng passport-based identity probe and registers site auth commands (includes polling). |
| clis/jike/auth.js | Adds Jike identity probe using localStorage token + gateway API and registers site auth commands (includes polling). |
| cli-manifest.json | Adds login and whoami commands for jike/jimeng/maimai/nowcoder. |
Comments suppressed due to low confidence (1)
clis/maimai/auth.js:1
- The regex captures JSON with a non-greedy
\\{[\\s\\S]*?\\}which will stop at the first}and can truncate objects containing nested objects/arrays (very likely for auserObj). This will causeJSON.parseto fail and incorrectly treat logged-in sessions as anonymous. Capture the full JSON.parse argument instead of a{...}fragment (e.g., capture everything up to the closing quote/paren) and then parse that captured string.
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+43
to
+47
| poll: async (page) => { | ||
| const probe = await page.evaluate(WHOAMI_PROBE); | ||
| if (!probe?.ok) throw new AuthRequiredError('web.okjike.com', 'Waiting for Jike login'); | ||
| return { user_id: probe.user_id, screen_name: probe.screen_name, username: probe.username }; | ||
| }, |
Comment on lines
+41
to
+45
| poll: async (page) => { | ||
| const probe = await page.evaluate(WHOAMI_PROBE); | ||
| if (!probe?.ok) throw new AuthRequiredError('jimeng.jianying.com', 'Waiting for Jimeng login'); | ||
| return { user_id: probe.user_id, screen_name: probe.screen_name }; | ||
| }, |
Comment on lines
+43
to
+44
| await page.goto('https://www.nowcoder.com/'); | ||
| await page.wait(2); |
Covers the four single-site login/whoami TODOs from the tracking issue, each verified against a logged-in session. Refs jackwener#1876
7a3041f to
3deb96d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements the four single-site login/whoami TODOs from the tracking issue, built on the registerSiteAuthCommands framework and matching the merged weibo / gitee / deepseek / hupu adapters. Each site was verified end to end against a real logged-in browser session; the sample output below uses placeholder values.
Per-site approach:
tsession cookie via CDP getCookies; the numeric uid is read from the first nav profile link (the SSR avatar link, ahead of feed recommendations) and identity is confirmed through the gateway profile API at gw-c.nowcoder.com.userObj = JSON.parse('{...}')script (declared with let, so it never lands on window, and the userCardStr global is corrupted to "[object Object]"). The probe parses that JSON, whose presence is the login signal.All four use typed errors (AuthRequiredError when anonymous, CommandExecutionError on HTTP, parse, or layout drift), the discriminated-union probe shape, and CDP getCookies where a cookie gate applies. No silent return, sentinel row, or clamp.
Related issue: refs #1876 (the four single-site TODOs).
Type of Change
Checklist
Screenshots / Output
Verified on logged-in sessions (values below are placeholders, not real account data):
Checks: npm run build, npm run check:typed-error-lint (new=0), npm run check:silent-column-drop (new=0) all pass. cli-manifest.json regenerated (adds only the 8 login/whoami command entries).