@magpie-community/opencode-workbuddy-auth 0.2.20 → 0.2.22
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 +4 -1
- package/index.mjs +22 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -359,7 +359,10 @@ credit packs) and platform rewards (gifted and activity credits,
|
|
|
359
359
|
against plan_bonus, addon and benefit); a summary without them is split
|
|
360
360
|
by package code as WorkBuddy's client does. Only one of the two stops the
|
|
361
361
|
account, since WorkBuddy serves it while any credits are left: the extra
|
|
362
|
-
window is set aside until the plan's credits are spent
|
|
362
|
+
window is set aside until the plan's credits are spent, then the plan's
|
|
363
|
+
is. Extra credits only the detail lists carry (a China-site free
|
|
364
|
+
account's summary can list the plan's base alone) are their own "Extra
|
|
365
|
+
credits" window by the same rule (ferock on Discord). A summary with
|
|
363
366
|
only one kind keeps the one "Credits" window (akic404 on Discord; since
|
|
364
367
|
0.2.16 the plan's bonus is extra too, Jiabubu on Discord).
|
|
365
368
|
|
package/index.mjs
CHANGED
|
@@ -15,7 +15,6 @@ import { homedir } from "node:os"
|
|
|
15
15
|
import { isAbsolute, join } from "node:path"
|
|
16
16
|
import { gzipSync } from "node:zlib"
|
|
17
17
|
|
|
18
|
-
const APP_VERSION = "2.0.0" // the version WorkBuddy's sign-in page is opened with
|
|
19
18
|
const POLL_MS = 1000
|
|
20
19
|
const SIGN_IN_MS = 5 * 60 * 1000
|
|
21
20
|
const EARLY_MS = 60 * 1000 // a token this close to its end is refreshed before a request
|
|
@@ -1755,7 +1754,12 @@ async function browserSignIn(site) {
|
|
|
1755
1754
|
if (!state?.state || !state?.authUrl) throw new Error(`${site.name} gave no sign-in page`)
|
|
1756
1755
|
const url = new URL(state.authUrl)
|
|
1757
1756
|
if (url.protocol !== "https:") throw new Error(`${site.name}'s sign-in page isn't https`)
|
|
1758
|
-
|
|
1757
|
+
// the desktop app's own version, as WorkBuddy desktop opens it
|
|
1758
|
+
// (openAuthUrl: version = CLIENT_INFO_PLUGIN_VERSION, the app's version).
|
|
1759
|
+
// The China build's page hides 企业微信 (WeCom) for a version under 5.8.0
|
|
1760
|
+
// (its signin-callback chunk: platform workbuddy and version >= "5.8.0"),
|
|
1761
|
+
// so the 2.0.0 sent before offered no WeCom sign-in (shenyebuwu on Discord)
|
|
1762
|
+
url.searchParams.set("version", site.app)
|
|
1759
1763
|
url.searchParams.set("loginSessionId", hex())
|
|
1760
1764
|
return {
|
|
1761
1765
|
url: url.toString(),
|
|
@@ -3899,24 +3903,30 @@ function makePlugin(site) {
|
|
|
3899
3903
|
const aside = extra ? (stops === credits ? extra : credits) : null
|
|
3900
3904
|
if (aside) Object.assign(aside, runsOutOf(sum, packages, Date.now(), (code) => ofPlan(code) === (aside === credits)) ?? {})
|
|
3901
3905
|
// the summary of the plan's credits alone: the extra ones
|
|
3902
|
-
// only the detail lists have (listedExtra) are their window
|
|
3903
|
-
//
|
|
3904
|
-
//
|
|
3905
|
-
//
|
|
3906
|
+
// only the detail lists have (listedExtra) are their window.
|
|
3907
|
+
// As with the summary's split (usageOf), one of the two stops
|
|
3908
|
+
// the account: the plan's, until its credits are spent with
|
|
3909
|
+
// extra ones left. WorkBuddy goes on serving such an account on
|
|
3910
|
+
// its extra credits (ferock on Discord, a China-site account
|
|
3911
|
+
// at "500 / 500" moved off while its extra ones were left).
|
|
3906
3912
|
const kinds = !extra && kindsOf(sum, site)
|
|
3907
3913
|
const more = kinds && kinds.plan.total > 0 && kinds.extra.total === 0 ? listedExtra(sum, packages, site) : null
|
|
3908
3914
|
if (more) {
|
|
3909
3915
|
const { runsOutAt, runsOut, ...counts } = more
|
|
3910
|
-
const w = { ...creditWindow("Extra credits", counts),
|
|
3916
|
+
const w = { ...creditWindow("Extra credits", counts), ...(runsOutAt ? { runsOutAt, runsOut } : {}) }
|
|
3917
|
+
const planSpent = credits.amount >= credits.limit && counts.used < counts.total
|
|
3918
|
+
if (planSpent) credits.aside = true
|
|
3919
|
+
else w.aside = true
|
|
3911
3920
|
out.windows.splice(out.windows.indexOf(credits) + 1, 0, w)
|
|
3912
|
-
// and, as with the split's, the soonest
|
|
3921
|
+
// and, as with the split's, the soonest credits to lapse are
|
|
3913
3922
|
// the account's too, on the window that stops it: routing
|
|
3914
3923
|
// reads none set aside, so an account whose extra credits
|
|
3915
3924
|
// expire first went unknown to it (Kayphoon on Discord)
|
|
3916
|
-
const
|
|
3917
|
-
const
|
|
3918
|
-
|
|
3919
|
-
|
|
3925
|
+
const [stops, other] = planSpent ? [w, credits] : [credits, w]
|
|
3926
|
+
const at = other.runsOutAt ? Date.parse(other.runsOutAt) : 0
|
|
3927
|
+
const was = stops.runsOutAt ? Date.parse(stops.runsOutAt) : 0
|
|
3928
|
+
if (at > 0 && (!was || at < was)) Object.assign(stops, { runsOutAt: other.runsOutAt, runsOut: other.runsOut })
|
|
3929
|
+
else if (at > 0 && at === was) stops.runsOut = (stops.runsOut ?? 0) + other.runsOut
|
|
3920
3930
|
}
|
|
3921
3931
|
} catch {}
|
|
3922
3932
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-workbuddy-auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.22",
|
|
4
4
|
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./opencode.mjs",
|