@magpie-community/opencode-qoder-auth 0.2.42 → 0.2.43
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/README.md +13 -0
- package/index.mjs +39 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -390,6 +390,19 @@ Qoder CN's `runtime-info` for environment `0` (the international one is
|
|
|
390
390
|
- `<openapi>` is `openapi.qoder.sh` (Qoder) or `openapi.qoder.com.cn`
|
|
391
391
|
(Qoder CN). Other pages on those hosts are still refused.
|
|
392
392
|
|
|
393
|
+
**When it is asked (0.2.43).** The daily 100 credits are a campaign of
|
|
394
|
+
their own each day, listed from 10:00 (UTC+8) to 09:59 the next day
|
|
395
|
+
(`startAt`/`endAt`; the campaign's own text says "Daily reset: 10:00
|
|
396
|
+
(UTC+8)", a live list on 2026-10-28). A check-in before 10:00 meets the day
|
|
397
|
+
before's campaign: it claims that one if it is still open. Every answer
|
|
398
|
+
that knows the window carries `until`, the next campaign's opening (a day
|
|
399
|
+
after this one's start, or its end when it runs longer) plus a minute, and
|
|
400
|
+
magpie (with `until` support) asks again then, so today's credits are
|
|
401
|
+
claimed a minute or two after 10:00 (UTC+8), whatever the computer's time
|
|
402
|
+
zone, with nothing to set. Between the old campaign's end at 09:59 and
|
|
403
|
+
10:00 the check-in is `failed` with `until` 10:01. An older magpie ignores
|
|
404
|
+
`until` and asks once a Beijing calendar day, as before.
|
|
405
|
+
|
|
393
406
|
Taken from [wallechfox/qoder-checkin](https://github.com/wallechfox/qoder-checkin),
|
|
394
407
|
which a user reports works, and Qoder desktop 0.4.3's campaign requests.
|
|
395
408
|
International campaign discovery was checked with a real account on
|
package/index.mjs
CHANGED
|
@@ -2089,6 +2089,36 @@ function gfmt(n) {
|
|
|
2089
2089
|
|
|
2090
2090
|
const RFC3339 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(\.\d+)?(Z|[+-]\d\d:\d\d)$/i
|
|
2091
2091
|
|
|
2092
|
+
// Qoder's daily credits are a campaign of their own each day, listed from
|
|
2093
|
+
// 10:00 (UTC+8) to 09:59 the next day: its startAt and endAt, and its own
|
|
2094
|
+
// words, "Daily reset: 10:00 (UTC+8)" (a live list, 2026-10-28; sdytman on
|
|
2095
|
+
// Discord: qoder每天10点开始签到). So the check-in's day is the campaign's,
|
|
2096
|
+
// not the calendar's in any zone: a check-in before 10:00 meets the day
|
|
2097
|
+
// before's campaign, and the next one opens a day after that one's start,
|
|
2098
|
+
// a minute after its end. A check-in says when (until, RFC 3339), and
|
|
2099
|
+
// magpie asks again then, whatever the machine's time zone.
|
|
2100
|
+
const DAY_MS = 86_400_000
|
|
2101
|
+
// a minute's room for a computer clock that runs ahead of Qoder's
|
|
2102
|
+
const OPEN_ROOM_MS = 60_000
|
|
2103
|
+
|
|
2104
|
+
// at is a time Qoder gives, in seconds or milliseconds, as milliseconds.
|
|
2105
|
+
const at = (v) => {
|
|
2106
|
+
const n = Number(v)
|
|
2107
|
+
if (v === null || v === undefined || v === "" || !Number.isFinite(n) || n <= 0) return undefined
|
|
2108
|
+
return n > 1e12 ? n : n * 1000
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
// nextOpens is when the campaign after c is expected to open: a day after
|
|
2112
|
+
// c's start, or c's end when it runs longer than a day.
|
|
2113
|
+
const nextOpens = (c) => {
|
|
2114
|
+
const start = at(c?.startAt), end = at(c?.endAt)
|
|
2115
|
+
if (end === undefined) return undefined
|
|
2116
|
+
return start === undefined ? end : Math.max(end, start + DAY_MS)
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
// askAgain is a check-in's until: when to ask again, with room.
|
|
2120
|
+
const askAgain = (t) => (Number.isFinite(t) ? { until: new Date(t + OPEN_ROOM_MS).toISOString() } : {})
|
|
2121
|
+
|
|
2092
2122
|
// when is a time Qoder gives: an RFC 3339 string, else seconds or
|
|
2093
2123
|
// milliseconds, as a number or its text.
|
|
2094
2124
|
function when(v) {
|
|
@@ -2586,16 +2616,21 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2586
2616
|
}
|
|
2587
2617
|
if (listRes.status !== 200) return { outcome: "failed", message: `campaigns: HTTP ${listRes.status}` }
|
|
2588
2618
|
const now = Date.now()
|
|
2589
|
-
const active = (c) => (
|
|
2619
|
+
const active = (c) => (at(c.startAt) ?? -Infinity) <= now && now < (at(c.endAt) ?? Infinity)
|
|
2590
2620
|
const campaigns = (Array.isArray(list.campaigns) ? list.campaigns : []).filter((x) => x?.actionType === "CLAIM_BENEFIT")
|
|
2591
2621
|
const campaign = campaigns.find((x) => x.claimStatus === "CLAIMABLE")
|
|
2592
2622
|
if (!campaign) {
|
|
2593
2623
|
const done = campaigns.find((x) => x.claimStatus === "CLAIMED" && active(x))
|
|
2594
2624
|
if (done) {
|
|
2595
2625
|
const amount = Number(done.benefit?.amount)
|
|
2596
|
-
return { outcome: "done", ...(Number.isFinite(amount) && amount > 0 ? { credit: amount } : {}) }
|
|
2626
|
+
return { outcome: "done", ...(Number.isFinite(amount) && amount > 0 ? { credit: amount } : {}), ...askAgain(nextOpens(done)) }
|
|
2627
|
+
}
|
|
2628
|
+
// the next day's credits open at a time the list says: ask then,
|
|
2629
|
+
// not half an hour later
|
|
2630
|
+
if (campaigns.length) {
|
|
2631
|
+
const next = Math.min(...campaigns.flatMap((c) => [at(c.startAt), nextOpens(c)]).filter((t) => t > now))
|
|
2632
|
+
return { outcome: "failed", message: "campaigns: today's credits aren't offered yet", ...askAgain(next) }
|
|
2597
2633
|
}
|
|
2598
|
-
if (campaigns.length) return { outcome: "failed", message: "campaigns: today's credits aren't offered yet" }
|
|
2599
2634
|
// Asked without Qoder CN's identity and offered nothing: what an
|
|
2600
2635
|
// international list says to a request without one, so say why
|
|
2601
2636
|
// (no Qoder CN on this machine) or ask again (it didn't answer).
|
|
@@ -2620,7 +2655,7 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
2620
2655
|
if (claimRes.status !== 200) return { outcome: "failed", message: `claim: HTTP ${claimRes.status}` }
|
|
2621
2656
|
if (said === "CLAIMED") {
|
|
2622
2657
|
const amount = Number(claim?.benefit?.amount ?? claim?.data?.benefit?.amount ?? campaign.benefit?.amount)
|
|
2623
|
-
return { outcome: "claimed", ...(Number.isFinite(amount) && amount > 0 ? { credit: amount } : {}) }
|
|
2658
|
+
return { outcome: "claimed", ...(Number.isFinite(amount) && amount > 0 ? { credit: amount } : {}), ...askAgain(nextOpens(campaign)) }
|
|
2624
2659
|
}
|
|
2625
2660
|
return { outcome: "failed", message: `claim: ${said || "unknown answer"}` }
|
|
2626
2661
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-qoder-auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.43",
|
|
4
4
|
"description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship (VPC)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|