minimax 0.1.4: the check-in is asked as the account (its user id), as MiniMax Code's own /checkin asks it (Magic_zero on Discord)

Magic_zero's international (minimax-code-global) account failed the daily
check-in with "check-in: the sign-in was refused (HTTP 401)" while the same
account chatted through magpie and checked in by hand on agent.minimax.io.

Cause, from MiniMax Code's own bundle (@minimax-ai/code 0.6.12, read from
npm): its /checkin client (signin/status and signin/claim, chunk-5ADYFF2U)
signs the request as the account, with user_id = the account's
realUserID, and refuses to ask at all without one ("MiniMax Code sign-in
is required"). Every other minimax-cloud call it makes (desktop error
reports, feedback, connectors, plugin cloud) names the user too; the error
report sends nothing but user_id beside the Bearer token. The plugin's
check-in went through signed() with no userID, so user_id=0. The chat path
(/mavis) and user/info don't go through minimax-cloud, which is why the
token works there. The same client also sends device_platform web,
is_desktop 1 and desktop_version, where the plugin's account API sends
device_platform mcode. The host and signature already matched
(agent.minimax.io; x-signature/yy as before).

This is read from the client's source; the server's rule (a check-in as
user 0 is a 401 on the international site) is inferred, not observed. The
web page (agent.minimax.io, prod-web-va-0.1.220) sends its own web
token in a `token` header, so it isn't the reference for this token kind.

What changed:
- signed() takes query overrides; the check-in passes user_id (the
  saved realUserID, or user/info's answer when the sign-in didn't keep
  it) and MiniMax Code's device_platform web, is_desktop 1,
  desktop_version 0.6.12. A user id that can't be read fails the
  check-in without asking the panel.
- The China site gets the same request (MiniMax Code sends it on both).
  Its host stays agent.minimax.cn.
- README says how the check-in is asked. 0.1.3 -> 0.1.4.

Tests (checkin.test.mjs):
- "the international check-in is asked as the account, not as user 0":
  a fake that 401s any user_id but the account's. On origin/main's
  index.mjs it fails with the reporter's exact message, "check-in: the
  sign-in was refused (HTTP 401)".
- an account saved without its user id has it looked up first; one
  whose id can't be read fails without a check-in.
- the signing test now checks user_id, device_platform web, is_desktop
  and desktop_version.
Against origin/main 7fdc07f's index.mjs: 4 of 21 check-in tests fail.
(origin/main has since moved to 26ddabe, a qoder change only.)

Run at this commit, rebased on origin/main 26ddabe:
- packages/minimax, HOME=$(mktemp -d) bun test: 54 pass, 0 fail.
- repo root, HOME=$(mktemp -d) bun test: 2117 pass, 0 fail.
- bun scripts/check.mjs (all packages): ok.

Not tried: a real MiniMax account on either site (the owner's magpie has
none signed in, and no one's credentials were used). Whether the China
site now answers the same is not seen either; MiniMax Code sends these
params there too. If the 401 stays, the next evidence is the failing
request's reply body (`{"error": ...}`) from the user.
This commit is contained in:
yetone
2026-10-22 19:01:07 +08:00
parent 26ddabe4de
commit 4d73d22010
4 changed files with 64 additions and 12 deletions
+3 -1
View File
@@ -118,7 +118,9 @@ These are read the way MiniMax Code reads them, with its signed account API.
The account's daily check-in (每日签到) is claimed through the same sign-in: The account's daily check-in (每日签到) is claimed through the same sign-in:
the plugin reads the panel (`/minimax-cloud/api/v1/signin/status`) and the plugin reads the panel (`/minimax-cloud/api/v1/signin/status`) and
claims the day's credits (`/minimax-cloud/api/v1/signin/claim`) with the claims the day's credits (`/minimax-cloud/api/v1/signin/claim`) with the
same signed account API. magpie can run it once a day per account, when its same signed account API, asked as MiniMax Code's own `/checkin` asks them:
as the account (its MiniMax user id, looked up first when the sign-in
didn't keep it), from the desktop client. magpie can run it once a day per account, when its
MiniMax check-in switch is on; Settings → Usage → Plugins has that switch MiniMax check-in switch is on; Settings → Usage → Plugins has that switch
and a *Check in now* button, and the outcome — claimed, done, inactive, and a *Check in now* button, and the outcome — claimed, done, inactive,
ineligible, with the streak — lands on the account's Usage card. ineligible, with the streak — lands on the account's Usage card.
+42 -3
View File
@@ -3,7 +3,7 @@
// minimax2api worked them out). Everything runs against the local fake. // minimax2api worked them out). Everything runs against the local fake.
import "./nonet.mjs" import "./nonet.mjs"
import { afterEach, expect, test } from "bun:test" import { afterEach, expect, test } from "bun:test"
import { MiniMaxCodeAuthPlugin } from "./index.mjs" import { MiniMaxCodeAuthPlugin, MiniMaxCodeGlobalAuthPlugin } from "./index.mjs"
import { _internal } from "./index.mjs" import { _internal } from "./index.mjs"
import { fakeMiniMax, json } from "./fake.mjs" import { fakeMiniMax, json } from "./fake.mjs"
@@ -12,7 +12,7 @@ afterEach(() => f?.close())
const STATUS = "/minimax-cloud/api/v1/signin/status" const STATUS = "/minimax-cloud/api/v1/signin/status"
const CLAIM = "/minimax-cloud/api/v1/signin/claim" const CLAIM = "/minimax-cloud/api/v1/signin/claim"
const auth = { type: "oauth", access: "tok", refresh: "r", expires: Date.now() + 3600_000, accountId: "a@example.com" } const auth = { type: "oauth", access: "tok", refresh: "r", expires: Date.now() + 3600_000, accountId: "a@example.com", realUserID: "u-42" }
const day = (over = {}) => ({ day_no: 1, points: 10, status: 2, is_today: true, ...over }) const day = (over = {}) => ({ day_no: 1, points: 10, status: 2, is_today: true, ...over })
@@ -78,12 +78,51 @@ test("the check-in requests are signed like the account API", async () => {
expect(r.headers.get("yy")).toBeTruthy() expect(r.headers.get("yy")).toBeTruthy()
expect(r.headers.get("x-timestamp")).toBeTruthy() expect(r.headers.get("x-timestamp")).toBeTruthy()
expect(r.headers.get("x-signature")).toBeTruthy() expect(r.headers.get("x-signature")).toBeTruthy()
expect(r.query.get("device_platform")).toBe("mcode") expect(r.query.get("device_platform")).toBe("web")
expect(r.query.get("is_desktop")).toBe("1")
expect(r.query.get("desktop_version")).toBeTruthy()
expect(r.query.get("client")).toBe("mcode")
expect(r.query.get("user_id")).toBe("u-42")
expect(r.query.get("timezone_offset")).toBe(String(new Date().getTimezoneOffset() * -60)) expect(r.query.get("timezone_offset")).toBe(String(new Date().getTimezoneOffset() * -60))
} }
expect(claim?.text).toBe("{}") expect(claim?.text).toBe("{}")
}) })
// Magic_zero on Discord: the international site's check-in was refused
// (HTTP 401) while the same account chatted. MiniMax Code asks it as the
// account (user_id its realUserID); the fake turns away anyone else, as
// a check-in asked as user 0 was.
const asTheAccount = (r) => (r.query.get("user_id") === "u-42" ? null : new Response("", { status: 401 }))
test("the international check-in is asked as the account, not as user 0", async () => {
f = fakeMiniMax()
f.route("GET " + STATUS, (r) => asTheAccount(r) ?? json({ base_resp: { status_code: 0 }, data: { days: week(2) } }))
f.route("POST " + CLAIM, (r) => asTheAccount(r) ?? json({ base_resp: { status_code: 0 }, data: { claim_result: 1, points: 20 } }))
const plugin = await MiniMaxCodeGlobalAuthPlugin({ client: { auth: { set: async () => {} } } })
expect(await plugin.auth.checkin(async () => auth)).toEqual({ outcome: "claimed", credit: 20, streak: 2 })
expect(f.seen.filter((r) => r.path === STATUS || r.path === CLAIM).map((r) => r.query.get("user_id"))).toEqual(["u-42", "u-42"])
})
test("an account saved without its user id has it looked up before the check-in", async () => {
f = fakeMiniMax()
f.route("GET /v1/api/user/info", () => json({ statusInfo: { code: 0 }, data: { userInfo: { realUserID: "u-42", userEmail: "a@example.com" } } }))
f.route("GET " + STATUS, (r) => asTheAccount(r) ?? json({ base_resp: { status_code: 0 }, data: { days: week(1, { status: 3 }) } }))
const plugin = await MiniMaxCodeGlobalAuthPlugin({ client: { auth: { set: async () => {} } } })
const { realUserID, ...noID } = auth
expect(await plugin.auth.checkin(async () => noID)).toEqual({ outcome: "done", credit: 10, streak: 1 })
expect(f.seen.map((r) => r.path)).toEqual(["/v1/api/user/info", STATUS])
})
test("an account whose user id can't be read is failed without a check-in", async () => {
f = fakeMiniMax()
f.route("GET /v1/api/user/info", () => new Response("", { status: 401 }))
const plugin = await MiniMaxCodeGlobalAuthPlugin({ client: { auth: { set: async () => {} } } })
const { realUserID, ...noID } = auth
const out = await plugin.auth.checkin(async () => noID)
expect(out.outcome).toBe("failed")
expect(f.seen.filter((r) => r.path === STATUS)).toHaveLength(0)
})
test("the China panel is asked on the chat host, not the account host", async () => { test("the China panel is asked on the chat host, not the account host", async () => {
f = fakeMiniMax() f = fakeMiniMax()
const was = { ..._internal.SITES["minimax-code"] } const was = { ..._internal.SITES["minimax-code"] }
+18 -7
View File
@@ -342,10 +342,11 @@ class SignInExpired extends Error {
// signed is a request of MiniMax Code's account API, signed as mcode signs // signed is a request of MiniMax Code's account API, signed as mcode signs
// one: yy over the path and query, the body ("{}" for a GET) and the time; // one: yy over the path and query, the body ("{}" for a GET) and the time;
// x-signature over the time (and the body of a POST). // x-signature over the time (and the body of a POST).
function signed(site, path, { access, userID, body, origin = site.agent, now = Date.now(), tz = new Date().getTimezoneOffset() * -60, platform = process.platform } = {}) { function signed(site, path, { access, userID, body, origin = site.agent, query, now = Date.now(), tz = new Date().getTimezoneOffset() * -60, platform = process.platform } = {}) {
const url = new URL(path, origin) const url = new URL(path, origin)
url.search = new URLSearchParams({ url.search = new URLSearchParams({
device_platform: "mcode", biz_id: "3", app_id: "3001", version_code: "22201", device_platform: "mcode", biz_id: "3", app_id: "3001", version_code: "22201",
...query,
unix: String(now), timezone_offset: String(tz), sys_language: site.lang, lang: site.lang, unix: String(now), timezone_offset: String(tz), sys_language: site.lang, lang: site.lang,
device_id: "0", os_name: platform, browser_name: "mcode", user_id: String(userID ?? "").trim() || "0", client: "mcode", device_id: "0", os_name: platform, browser_name: "mcode", user_id: String(userID ?? "").trim() || "0", client: "mcode",
}).toString() }).toString()
@@ -529,8 +530,17 @@ function usageOf(m, windows = []) {
// already today. Both calls use the same signed account client as the rest // already today. Both calls use the same signed account client as the rest
// of the account API: the gateway checks the signature, and a Bearer-only // of the account API: the gateway checks the signature, and a Bearer-only
// Bun fetch is not what MiniMax Code sends. // Bun fetch is not what MiniMax Code sends.
async function checkinCall(site, access, method, path, body) { //
const opts = { access, origin: site.llm } // They go as MiniMax Code's own /checkin sends them (its daily-check-in
// gateway, 0.6.12): as the account, user_id its realUserID — MiniMax Code
// won't ask without one, and every minimax-cloud call it makes names the
// user — and the desktop's device_platform web, is_desktop 1 and its
// version. The international site turns away a check-in asked as user 0
// with a 401 while the same token chats (Magic_zero on Discord).
const CHECKIN_QUERY = { device_platform: "web", is_desktop: "1", desktop_version: "0.6.12" }
async function checkinCall(site, access, userID, path, body) {
const opts = { access, userID, origin: site.llm, query: CHECKIN_QUERY }
if (body !== undefined) opts.body = body if (body !== undefined) opts.body = body
return accountCall(site, path, opts, "check-in") return accountCall(site, path, opts, "check-in")
} }
@@ -540,8 +550,9 @@ async function checkinCall(site, access, method, path, body) {
// hasn't started, or the panel has none), ineligible (the day isn't // hasn't started, or the panel has none), ineligible (the day isn't
// available); a throw is failed. streak counts the claimed days up to and // available); a throw is failed. streak counts the claimed days up to and
// including today. // including today.
async function checkinOf(site, access) { async function checkinOf(site, access, userID) {
const panel = await checkinCall(site, access, "GET", "/minimax-cloud/api/v1/signin/status") if (!String(userID ?? "").trim()) userID = (await identity(site, access)).realUserID
const panel = await checkinCall(site, access, userID, "/minimax-cloud/api/v1/signin/status")
const days = Array.isArray(panel?.data?.days) ? panel.data.days : null const days = Array.isArray(panel?.data?.days) ? panel.data.days : null
if (!days?.length) throw new Error("check-in: no panel in the reply") if (!days?.length) throw new Error("check-in: no panel in the reply")
const sorted = [...days].sort((a, b) => (a?.day_no ?? 0) - (b?.day_no ?? 0)) const sorted = [...days].sort((a, b) => (a?.day_no ?? 0) - (b?.day_no ?? 0))
@@ -561,7 +572,7 @@ async function checkinOf(site, access) {
return { outcome: "done", ...(points ? { credit: points } : {}), streak: streakFrom(sorted.indexOf(today)) } return { outcome: "done", ...(points ? { credit: points } : {}), streak: streakFrom(sorted.indexOf(today)) }
} }
if (today.status === 2) { if (today.status === 2) {
const claim = await checkinCall(site, access, "POST", "/minimax-cloud/api/v1/signin/claim", {}) const claim = await checkinCall(site, access, userID, "/minimax-cloud/api/v1/signin/claim", {})
const r = pos(claim?.data, "claim_result") const r = pos(claim?.data, "claim_result")
const credit = pos(claim?.data, "points") const credit = pos(claim?.data, "points")
const got = { ...(credit ? { credit } : {}), streak: streakFrom(sorted.indexOf(today) - 1) + 1 } const got = { ...(credit ? { credit } : {}), streak: streakFrom(sorted.indexOf(today) - 1) + 1 }
@@ -822,7 +833,7 @@ function makePlugin(site) {
return { outcome: "failed", message: e?.message ?? String(e), ...(e?.signIn ? { signIn: e.signIn } : {}) } return { outcome: "failed", message: e?.message ?? String(e), ...(e?.signIn ? { signIn: e.signIn } : {}) }
} }
try { try {
return await checkinOf(site, a.access) return await checkinOf(site, a.access, a.realUserID)
} catch (e) { } catch (e) {
return { outcome: "failed", message: e?.message ?? String(e), ...(e?.signIn ? { signIn: e.signIn } : {}) } return { outcome: "failed", message: e?.message ?? String(e), ...(e?.signIn ? { signIn: e.signIn } : {}) }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@magpie-community/opencode-minimax-auth", "name": "@magpie-community/opencode-minimax-auth",
"version": "0.1.3", "version": "0.1.4",
"description": "OpenCode provider plugins for MiniMax Code accounts: their credits and M Plan, China (minimax-code) and international (minimax-code-global), with MiniMax Code's own device sign-in", "description": "OpenCode provider plugins for MiniMax Code accounts: their credits and M Plan, China (minimax-code) and international (minimax-code-global), with MiniMax Code's own device sign-in",
"type": "module", "type": "module",
"main": "./index.mjs", "main": "./index.mjs",