zcode 0.1.50: a claim's code 1004 is ineligible, read again in half an hour (kongbai01203, #729)
A claim ZCode answers with code 1004 (HTTP 400, a plan the account is not offered at that moment) is read as ineligible, naming the plan, and asked again half an hour out as an inactive is, instead of failed. Captcha (3007) is unchanged: still "claim it in the ZCode app", never solved. Version 0.1.50 (maintainer bump on the PR branch). Run at 6837f27e on mote (macOS, Bun 1.4.2, sandbox HOME): - packages/zcode `bun test`: 199 pass, 0 fail. `bun scripts/check.mjs zcode`: ok. - Broken by hand: dropping the 1004 branch in claimOne turns 3 checkin tests red; dropping the recheck `until` on an ineligible turns 2 red. - magpie's host accepts "ineligible" with an until and asks again at it (host.js checkinOutcomes, plugin_checkin.go ValidUntil). Not tried: a real 1004. The owner's one ZCode account answered 3007 (captcha) for zcode-v3-start-plan-1029 and zcode-v3-start-plan-gb-1104 under both 3.16.3's and 3.17.2's header, so the fixture's message text is the author's, from their six accounts on 11-04. Co-authored-by: kongbai01203 <kongbai01203@users.noreply.github.com>
This commit is contained in:
co-authored by
kongbai01203
parent
0bd00f0c72
commit
81df338116
@@ -294,7 +294,9 @@ and again, all day while the feed names no plan — one GET, nothing
|
||||
posted: ZCode drops plans into the feed on its own schedule (a weekend
|
||||
banner starting at 19:00 Beijing, say), and one that arrives
|
||||
after the day's ask used to sit unclaimed past its short life. The
|
||||
other answers stand for the day: a claimed plan leaves the feed, so
|
||||
other answers stand for the day — but an *ineligible* (code 1004, below)
|
||||
is read again in half an hour, as an inactive is: a claimed plan leaves
|
||||
the feed, so
|
||||
asking again half an hour later would find nothing and flip the card
|
||||
from "Checked in today" to "No check-in event now"; a captcha plan
|
||||
re-asked makes ZCode demand its captcha again; a done plan re-asked
|
||||
@@ -313,6 +315,14 @@ the body's code, not the HTTP status:
|
||||
(11-03: seven accounts' ZCODE GLOBAL BUILD all answered 3007). Once
|
||||
claimed there, the gift lands on the account and freeFirst spends it
|
||||
like any other;
|
||||
- code 1004 "…not eligible for this plan yet" (HTTP 400): *ineligible*,
|
||||
ZCode is not offering this account the plan at that moment. It is read
|
||||
again half an hour out, since a plan can be offered later in the day
|
||||
(11-04: an account's GLOBAL BUILD banner appeared 28 minutes after it
|
||||
signed in). When *every* account answers 1004, check `APP_VERSION`
|
||||
first: six accounts all answered 1004 under 3.16.3's header, and four
|
||||
of them claimed with code 0 under 3.17.2's, one night, with nothing
|
||||
else changed;
|
||||
- anything else, an HTTP error without a code, or a reply that isn't
|
||||
JSON: *failed*, which magpie asks again later that day. It is never
|
||||
taken as claimed, and a failed claim leaves the account's sign-in
|
||||
|
||||
@@ -72,6 +72,10 @@ const CLAIMED_BEFORE = '{"code":1003,"msg":"target already exists","data":{"serv
|
||||
const CLAIMED_NOW = '{"code":0,"msg":""}'
|
||||
// the 10-06 answer to a claim without the app's captcha (#30)
|
||||
const CAPTCHA = '{"code":3007,"msg":"captcha verify failed"}'
|
||||
// 11-04: the answer to a claim for a plan the account is not offered yet.
|
||||
// The same six accounts answered it under an older APP_VERSION's header
|
||||
// and four of them claimed with code 0 under 3.17.2's.
|
||||
const NOT_ELIGIBLE = '{"code":1004,"msg":"your account is not eligible for this plan yet"}'
|
||||
|
||||
const PREVIEW = "/api/v1/zcode-plan/billing/preview"
|
||||
const CLAIM = "/api/v1/zcode-plan/billing/claim"
|
||||
@@ -112,6 +116,9 @@ test("an inactive says until half an hour out; claimed, done, captcha and failed
|
||||
none(await checkin())
|
||||
claimWith(() => json(CAPTCHA, 400), touchOf(WEEKEND))
|
||||
none(await checkin())
|
||||
// a plan not offered now can be offered later in the day: read again
|
||||
claimWith(() => json(NOT_ELIGIBLE), touchOf(WEEKEND))
|
||||
soon(await checkin())
|
||||
// a failed check-in settles for none: magpie asks a failed again itself
|
||||
claimWith(() => json(CLAIMED_NOW), () => { throw new Error("feed unreachable") })
|
||||
none(await checkin())
|
||||
@@ -182,6 +189,23 @@ test("a claim ZCode wants the app's captcha for is captcha: claimed in the ZCode
|
||||
expect(r.message).toContain("ZCode Trust Build: claim it in the ZCode app (captcha verify failed)")
|
||||
})
|
||||
|
||||
test("a claim ZCode is not offering yet (code 1004) is ineligible, read again later", async () => {
|
||||
claimWith(() => json(NOT_ELIGIBLE), touchOf([TRUST, "ZCode Trust Build"]))
|
||||
const r = await checkin()
|
||||
expect(r.outcome).toBe("ineligible")
|
||||
expect(r.message).toBe("ZCode Trust Build: your account is not eligible for this plan yet")
|
||||
const t = Date.parse(r.until)
|
||||
expect(t).toBeGreaterThan(Date.now() + 25 * 60_000)
|
||||
expect(t).toBeLessThan(Date.now() + 35 * 60_000)
|
||||
})
|
||||
|
||||
test("a 1004 beside a claimed plan is claimed, naming the one not offered", async () => {
|
||||
claimWith((id) => (id === GLOBAL ? json(NOT_ELIGIBLE) : json(CLAIMED_NOW)), touchOf([TRUST, "ZCode Trust Build"], [GLOBAL, "ZCODE GLOBAL BUILD"]))
|
||||
const r = await checkin()
|
||||
expect(r.outcome).toBe("claimed")
|
||||
expect(r.message).toContain("ZCODE GLOBAL BUILD: your account is not eligible for this plan yet")
|
||||
})
|
||||
|
||||
test("a claim that doesn't read is failed (unknown), never claimed", async () => {
|
||||
for (const answer of [
|
||||
() => json("", 500),
|
||||
|
||||
@@ -709,6 +709,12 @@ async function claimHint(s) {
|
||||
// (seen 10-06, #30).
|
||||
const CLAIMED_ALREADY = 1003
|
||||
const CAPTCHA = 3007
|
||||
// NOT_ELIGIBLE is /billing/claim's body code for a plan the account is not
|
||||
// offered at that moment: HTTP 400 {"code":1004,…}. A stale APP_VERSION
|
||||
// answers it for every account at once (11-04: six accounts all answered
|
||||
// 1004 under 3.16.3's header, and four of them claimed with code 0 under
|
||||
// 3.17.2's, one night, with nothing else changed).
|
||||
const NOT_ELIGIBLE = 1004
|
||||
const CAPTCHA_WORDS = /captcha/i
|
||||
|
||||
// The marketing feed and the claim are gated on the client's version:
|
||||
@@ -743,6 +749,7 @@ async function claimOne(s, planID) {
|
||||
const msg = typeof env?.msg === "string" ? env.msg : ""
|
||||
if (code === CAPTCHA || CAPTCHA_WORDS.test(msg)) return { outcome: "captcha", why: msg || `code ${code}` }
|
||||
if (code === CLAIMED_ALREADY) return { outcome: "done" }
|
||||
if (code === NOT_ELIGIBLE) return { outcome: "ineligible", why: msg || `code ${code}` }
|
||||
if (code === 0 && res.ok) return { outcome: "claimed" }
|
||||
if (!Number.isFinite(code)) return { outcome: "failed", why: `HTTP ${res.status}, unreadable reply ${String(text ?? "").trim().slice(0, 120) || "(empty)"}` }
|
||||
return { outcome: "failed", why: `${msg || "error"} (HTTP ${res.status}, code ${code})` }
|
||||
@@ -847,7 +854,9 @@ const recheck = () => new Date(Date.now() + RECHECK_MS).toISOString()
|
||||
// toClaim, the app's banners and its preview), as auth.checkin's answer:
|
||||
// inactive when neither lists one, claimed when one was claimed now,
|
||||
// done when each was claimed before, captcha when ZCode wants the app's
|
||||
// captcha for one (it is claimed in the ZCode app), failed when a list
|
||||
// captcha for one (it is claimed in the ZCode app), ineligible when
|
||||
// ZCode is not offering one at that moment (code 1004, read again later
|
||||
// in the day), failed when a list
|
||||
// or a claim can't be read. A failed one is asked again later in the
|
||||
// day, when a plan claimed now answers 1003. An inactive stands only
|
||||
// until RECHECK_MS from now, so a plan dropped into the feed later in
|
||||
@@ -867,6 +876,7 @@ async function claimDaily(s) {
|
||||
const said = [
|
||||
claimed.length ? `claimed ${claimed.join(", ")}` : "",
|
||||
...got.filter((g) => g.outcome === "captcha").map((g) => `${g.name}: claim it in the ZCode app (${g.why})`),
|
||||
...got.filter((g) => g.outcome === "ineligible").map((g) => `${g.name}: ${g.why}`),
|
||||
...got.filter((g) => g.outcome === "failed").map((g) => `${g.name}: ${g.why}`),
|
||||
...unread,
|
||||
].filter(Boolean).join("; ")
|
||||
@@ -876,6 +886,10 @@ async function claimDaily(s) {
|
||||
if (unread.length || got.some((g) => g.outcome === "failed")) return { outcome: "failed", message: said }
|
||||
if (got.some((g) => g.outcome === "captcha")) return { outcome: "captcha", message: said }
|
||||
if (claimed.length) return { outcome: "claimed", message: said }
|
||||
// a plan not offered now can be offered later in the day (11-04: an
|
||||
// account's GLOBAL BUILD banner showed 28 minutes after it signed in),
|
||||
// so an ineligible is read again half an hour out, as an inactive is
|
||||
if (got.some((g) => g.outcome === "ineligible")) return { outcome: "ineligible", message: said, until: recheck() }
|
||||
return { outcome: "done", message: `already claimed: ${named("done").join(", ")}` }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-zcode-auth",
|
||||
"version": "0.1.49",
|
||||
"version": "0.1.50",
|
||||
"description": "OpenCode provider plugin: signs in to Z.ai's or BigModel's (智谱) GLM Coding Plan as ZCode does, including team seats and ZCode's Start Plan, and claims its gift plans daily",
|
||||
"type": "module",
|
||||
"main": "./opencode.mjs",
|
||||
|
||||
Reference in New Issue
Block a user