Repository navigation
fix: 网页登录的结果少了 refresh,magpie 一格都不存(0.2.36) - #1
Merged
Merged
Conversation
「{user} 已登录,但 magpie 无法列出它」的真因不是国际站的 cookie,是登录返回值。
magpie 的插件宿主 host.js 的 save() 只有两条出口:
if ("refresh" in result) setAuth(oauth)
else if ("key" in result) setAuth(api)
本插件的 success 只有 access/expires/accountId/uid —— 两条都不命中,宿主既不保存
也不报错,界面照样显示「已登录」,而 plugin-auth.json 里没有记录,随后的
providers?wait=1 里就没有这个 account。
国内站与百智云一直用 API Key 方式登录(type: api,走 api 分支),所以「网页登录
从来没存下来过」一直没暴露,国际站第一个撞上。
- 新增 src/credential.mjs 的 signInSuccess():refresh 与 access 同值、expires 0;
五处 success 全部改走它
- tests/signin-contract.test.mjs:锁 refresh 位,并禁止生产代码再出现裸的
type: "success"
- 国际站删掉「用百智云账号开通」:实测它 302 到自己的 /oauth/authorize
(client_id 空),注入百智云会话也只落到首页,不会签发 session
- 桌面导入按域取 cookie 并恢复给国际站:桌面端的 mc_base_url 是二选一的一个值,
monkeycode-cookies.json 装的是当前那一站;读到另一站时明确说清
- AGENTS 0.6/0.7、docs/internals、README 同步实测结论
看两处事实:plugin-auth.json 里有没有 monkeycodeintl 的记录(含 uid)、 本机网关 /v1/models 里有没有 monkeycodeintl/… 。只读、不发写请求; 可选 --cookie 验一次平台会话。退出码 2 = 有判据不成立。
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.
根因
magpie 的插件宿主
host.js的save()只有两条保存出口:本插件的 success 一直是
{ type:"success", access, expires:0, accountId, uid }:既没有refresh也没有key,两条都不命中 —— 宿主既不保存也不报错,界面照旧显示「已登录」,而plugin-auth.json里没有记录。随后的providers?wait=1里找不到这个 account,就打出「{user} 已登录,但 magpie 无法列出它,请反馈此问题」。国内站与百智云一直用 API Key 方式登录(
type: "api",走 api 分支),所以「网页登录从来没存下来过」一直没暴露;国际站只能用网页 / GitHub / Google / 密码登录,第一个撞上。改动
src/credential.mjs的signInSuccess():refresh与access同值、expires: 0;五处 success(网页登录 / 账号密码 / 桌面导入 / SSO / 百智云)全部改走它tests/signin-contract.test.mjs:锁refresh位,并禁止生产代码再出现裸的type: "success"GET /api/v1/users/login302 到它自己的/oauth/authorize(client_id空),注入百智云会话走完只落到国际站首页,不签发 sessionmc_base_url是二选一的一个值,monkeycode-cookies.json装的是当前那一站;读到另一站时说清「登录的是另一个站点」而不是让上游 401 误导scripts/check-intl-signin.mjs:AGENTS 0.7 的两条判据做成一条命令(只读)验证
发布后的真机判据(AGENTS 0.7)
更新到 0.2.36 后在国际版点「浏览器登录」登一次,然后: