Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 208 additions & 0 deletions cli-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17179,6 +17179,38 @@
"sourceFile": "jike/like.js",
"navigateBefore": true
},
{
"site": "jike",
"name": "login",
"description": "Open jike login and wait until the browser session is authenticated",
"access": "write",
"domain": "web.okjike.com",
"strategy": "cookie",
"browser": true,
"args": [
{
"name": "timeout",
"type": "int",
"default": 300,
"required": false,
"help": "Maximum seconds to wait for the user to finish login"
}
],
"columns": [
"status",
"logged_in",
"site",
"user_id",
"screen_name",
"username"
],
"type": "js",
"modulePath": "jike/auth.js",
"sourceFile": "jike/auth.js",
"navigateBefore": false,
"siteSession": "persistent",
"defaultWindowMode": "foreground"
},
{
"site": "jike",
"name": "notifications",
Expand Down Expand Up @@ -17382,6 +17414,27 @@
"sourceFile": "jike/user.js",
"navigateBefore": "https://m.okjike.com"
},
{
"site": "jike",
"name": "whoami",
"description": "Show the current logged-in jike account",
"access": "read",
"domain": "web.okjike.com",
"strategy": "cookie",
"browser": true,
"args": [],
"columns": [
"logged_in",
"site",
"user_id",
"screen_name",
"username"
],
"type": "js",
"modulePath": "jike/auth.js",
"sourceFile": "jike/auth.js",
"navigateBefore": false
},
{
"site": "jimeng",
"name": "generate",
Expand Down Expand Up @@ -17453,6 +17506,37 @@
"sourceFile": "jimeng/history.js",
"navigateBefore": "https://jimeng.jianying.com"
},
{
"site": "jimeng",
"name": "login",
"description": "Open jimeng login and wait until the browser session is authenticated",
"access": "write",
"domain": "jimeng.jianying.com",
"strategy": "cookie",
"browser": true,
"args": [
{
"name": "timeout",
"type": "int",
"default": 300,
"required": false,
"help": "Maximum seconds to wait for the user to finish login"
}
],
"columns": [
"status",
"logged_in",
"site",
"user_id",
"screen_name"
],
"type": "js",
"modulePath": "jimeng/auth.js",
"sourceFile": "jimeng/auth.js",
"navigateBefore": false,
"siteSession": "persistent",
"defaultWindowMode": "foreground"
},
{
"site": "jimeng",
"name": "new",
Expand All @@ -17471,6 +17555,26 @@
"sourceFile": "jimeng/new.js",
"navigateBefore": "https://jimeng.jianying.com"
},
{
"site": "jimeng",
"name": "whoami",
"description": "Show the current logged-in jimeng account",
"access": "read",
"domain": "jimeng.jianying.com",
"strategy": "cookie",
"browser": true,
"args": [],
"columns": [
"logged_in",
"site",
"user_id",
"screen_name"
],
"type": "js",
"modulePath": "jimeng/auth.js",
"sourceFile": "jimeng/auth.js",
"navigateBefore": false
},
{
"site": "jimeng",
"name": "workspaces",
Expand Down Expand Up @@ -21142,6 +21246,38 @@
"modulePath": "lobsters/tag.js",
"sourceFile": "lobsters/tag.js"
},
{
"site": "maimai",
"name": "login",
"description": "Open maimai login and wait until the browser session is authenticated",
"access": "write",
"domain": "maimai.cn",
"strategy": "cookie",
"browser": true,
"args": [
{
"name": "timeout",
"type": "int",
"default": 300,
"required": false,
"help": "Maximum seconds to wait for the user to finish login"
}
],
"columns": [
"status",
"logged_in",
"site",
"user_id",
"name",
"company"
],
"type": "js",
"modulePath": "maimai/auth.js",
"sourceFile": "maimai/auth.js",
"navigateBefore": false,
"siteSession": "persistent",
"defaultWindowMode": "foreground"
},
{
"site": "maimai",
"name": "search-talents",
Expand Down Expand Up @@ -21266,6 +21402,27 @@
"sourceFile": "maimai/search-talents.js",
"navigateBefore": "https://maimai.cn"
},
{
"site": "maimai",
"name": "whoami",
"description": "Show the current logged-in maimai account",
"access": "read",
"domain": "maimai.cn",
"strategy": "cookie",
"browser": true,
"args": [],
"columns": [
"logged_in",
"site",
"user_id",
"name",
"company"
],
"type": "js",
"modulePath": "maimai/auth.js",
"sourceFile": "maimai/auth.js",
"navigateBefore": false
},
{
"site": "manus",
"name": "connectors",
Expand Down Expand Up @@ -22727,6 +22884,37 @@
"modulePath": "nowcoder/jobs.js",
"sourceFile": "nowcoder/jobs.js"
},
{
"site": "nowcoder",
"name": "login",
"description": "Open nowcoder login and wait until the browser session is authenticated",
"access": "write",
"domain": "nowcoder.com",
"strategy": "cookie",
"browser": true,
"args": [
{
"name": "timeout",
"type": "int",
"default": 300,
"required": false,
"help": "Maximum seconds to wait for the user to finish login"
}
],
"columns": [
"status",
"logged_in",
"site",
"user_id",
"nickname"
],
"type": "js",
"modulePath": "nowcoder/auth.js",
"sourceFile": "nowcoder/auth.js",
"navigateBefore": false,
"siteSession": "persistent",
"defaultWindowMode": "foreground"
},
{
"site": "nowcoder",
"name": "notifications",
Expand Down Expand Up @@ -23065,6 +23253,26 @@
"modulePath": "nowcoder/trending.js",
"sourceFile": "nowcoder/trending.js"
},
{
"site": "nowcoder",
"name": "whoami",
"description": "Show the current logged-in nowcoder account",
"access": "read",
"domain": "nowcoder.com",
"strategy": "cookie",
"browser": true,
"args": [],
"columns": [
"logged_in",
"site",
"user_id",
"nickname"
],
"type": "js",
"modulePath": "nowcoder/auth.js",
"sourceFile": "nowcoder/auth.js",
"navigateBefore": false
},
{
"site": "npm",
"name": "downloads",
Expand Down
48 changes: 48 additions & 0 deletions clis/jike/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { registerSiteAuthCommands } from '../_shared/site-auth.js';

// Jike web (web.okjike.com) is an SPA shell that stores a JWT in localStorage
// under JK_ACCESS_TOKEN and forwards it as the x-jike-access-token header to the
// api.ruguoapp.com gateway. The JWT payload is encrypted, so identity is read
// from the /1.0/users/profile endpoint rather than from the token or a cookie.
const WHOAMI_PROBE = `(async () => {
try {
const token = localStorage.getItem('JK_ACCESS_TOKEN') || '';
if (!token) return { kind: 'auth', detail: 'Jike JK_ACCESS_TOKEN missing from localStorage (anonymous)' };
const r = await fetch('https://api.ruguoapp.com/1.0/users/profile', {
headers: { 'x-jike-access-token': token, Accept: 'application/json' },
});
if (r.status === 401 || r.status === 403) return { kind: 'auth', detail: 'Jike users/profile HTTP ' + r.status };
if (!r.ok) return { kind: 'http', httpStatus: r.status };
const d = await r.json();
const u = d && d.user;
if (!u || !u.id) return { kind: 'auth', detail: 'Jike users/profile returned no user (anonymous)' };
return { ok: true, user_id: String(u.id), screen_name: String(u.screenName || ''), username: String(u.username || '') };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`;

async function verifyJikeIdentity(page) {
await page.goto('https://web.okjike.com/');
await page.wait(2);
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('web.okjike.com', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Jike users/profile`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Jike whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Jike probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, screen_name: probe.screen_name, username: probe.username };
}

registerSiteAuthCommands({
site: 'jike',
domain: 'web.okjike.com',
loginUrl: 'https://web.okjike.com/login',
columns: ['user_id', 'screen_name', 'username'],
verify: verifyJikeIdentity,
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 +43 to +47
});
46 changes: 46 additions & 0 deletions clis/jimeng/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { registerSiteAuthCommands } from '../_shared/site-auth.js';

// Jimeng (ByteDance) authenticates through the shared jianying passport. The
// /passport/account/info/v2/ endpoint returns the current account for the
// session cookies; an anonymous visitor comes back with is_visitor_account
// true and no user_id, so that flag is the login gate. Only the stable id and
// display name are surfaced (the payload also carries phone/email, which are
// intentionally not read).
const WHOAMI_PROBE = `(async () => {
try {
const r = await fetch('/passport/account/info/v2/?aid=513695', { credentials: 'include', headers: { Accept: 'application/json' } });
if (r.status === 401 || r.status === 403) return { kind: 'auth', detail: 'Jimeng passport HTTP ' + r.status };
if (!r.ok) return { kind: 'http', httpStatus: r.status };
const d = await r.json();
const u = d && d.data;
if (!u || !u.user_id || u.is_visitor_account) return { kind: 'auth', detail: 'Jimeng passport returned a visitor account (anonymous)' };
return { ok: true, user_id: String(u.user_id_str || u.user_id), screen_name: String(u.screen_name || u.name || '') };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`;

async function verifyJimengIdentity(page) {
await page.goto('https://jimeng.jianying.com/ai-tool/generate?type=image&workspace=0');
await page.wait(2);
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('jimeng.jianying.com', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Jimeng passport`);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Jimeng whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Jimeng probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, screen_name: probe.screen_name };
}

registerSiteAuthCommands({
site: 'jimeng',
domain: 'jimeng.jianying.com',
loginUrl: 'https://jimeng.jianying.com/',
columns: ['user_id', 'screen_name'],
verify: verifyJimengIdentity,
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 +41 to +45
});
Loading
Loading