magpie-marvis 0.2.4 → 0.2.5

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.
package/CHANGELOG.md CHANGED
@@ -3,7 +3,14 @@
3
3
  > 每个版本一节,**一条一行**,说用户能感知的变化。
4
4
  > 格式与规矩见 [UPDATING.md](./UPDATING.md)。
5
5
 
6
- ## 0.2.4 — 2026-11-06
6
+ ## 0.2.5 — 2026-11-06
7
+
8
+ **修复**
9
+
10
+ - **`state` 格式与客户端不一致**:app 是 `state=${Math.random()*100}`(**小数**,如 `31.1177412`),
11
+ 我写成了 `Math.floor(Math.random()*1e9)`(整数)。抓包确认服务端收到的是 `845583851` 这种
12
+ - **`loginType` 映射错了**:渲染层 `yct={QC:"1",WX:"2",WXAPP:"2"}`,
13
+ `Ual-Access-Login-Type` 应该是 `1`/`2`,我写的是 `6`/`5`
7
14
 
8
15
  **修复(`-109` 的最终根因)**
9
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magpie-marvis",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "magpie / OpenCode provider plugin for Tencent Marvis: its DeepSeek V4 Pro, Kimi K2.5, Claude Opus/Sonnet 4.6, GPT-5.4 and Hunyuan models through the Marvis model gateway — no API key to paste, sign in with QQ or WeChat.",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
@@ -226,7 +226,7 @@ export function parseLoginState(text) {
226
226
  openid: m[1],
227
227
  accessToken: m[2],
228
228
  refreshToken: m[3] || undefined,
229
- loginType: /^WX$/i.test(m[4] ?? "") ? "5" : "6",
229
+ loginType: /^WX/i.test(m[4] ?? "") ? "2" : "1",
230
230
  guid: memGuid ? memGuid[1].toLowerCase() : guid,
231
231
  expiresAt: expire ? Number(expire[1]) * 1000 : Date.now() + 30 * 24 * 3600_000,
232
232
  }
@@ -56,7 +56,9 @@ export function authorizeUrl(loginType, guid) {
56
56
  client_id: QQ_APP_ID,
57
57
  // ⚠ 必须带 ?login_type=QC,见 REDIRECT 上方说明
58
58
  redirect_uri: `${REDIRECT}?login_type=${loginType}`,
59
- state: String(Math.floor(Math.random() * 1e9)),
59
+ // ⚠ 必须与 Marvis 渲染层逐字一致:`state=${Math.random()*100}`
60
+ // 是**小数**(如 31.1177412),不是整数。服务端会拿它做校验,格式不符会被判参数无效。
61
+ state: String(Math.random() * 100),
60
62
  })
61
63
  return `https://graph.qq.com/oauth2.0/authorize?${p}`
62
64
  }
@@ -228,7 +230,9 @@ function normalize(info, accessToken, openid) {
228
230
  refreshToken: info?.refresh_token ? String(info.refresh_token) : undefined,
229
231
  nickname: info?.nick_name ? safeDecode(info.nick_name) : undefined,
230
232
  avatar: info?.head_img_url ?? undefined,
231
- loginType: "6",
233
+ // ⚠ `Ual-Access-Login-Type` 的真实取值:QC→"1"、WX/WXAPP→"2"
234
+ // (渲染层 `yct={QC:"1",WX:"2",WXAPP:"2"}`)。不是 6。
235
+ loginType: info?.login_type === "WX" || info?.login_type === "WXAPP" ? "2" : "1",
232
236
  expiresAt: expire > 1e9 ? expire * 1000 : Date.now() + 30 * 24 * 3600_000,
233
237
  }
234
238
  }