@magpie-community/opencode-workbuddy-auth 0.1.17 → 0.1.18
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 +2 -1
- package/index.mjs +16 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,8 @@ The package exports `WorkBuddyAuthPlugin` (`workbuddy`) and
|
|
|
24
24
|
- Windows: `~/AppData/Local/CodeBuddyExtension/…`
|
|
25
25
|
- Linux: `~/.local/share/CodeBuddyExtension/…`
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
WorkBuddy 5.6 and later keep the sign-in encrypted, which only the app
|
|
28
|
+
opens, so this way fails there and says so: use the browser sign-in.
|
|
28
29
|
|
|
29
30
|
A browser sign-in is kept as an OpenCode `oauth` auth: the access and
|
|
30
31
|
refresh tokens, their expiry, the user id and the domain; desktop's as a
|
package/index.mjs
CHANGED
|
@@ -931,6 +931,19 @@ function readDesktop(site) {
|
|
|
931
931
|
}
|
|
932
932
|
}
|
|
933
933
|
|
|
934
|
+
// notDesktop says why there is no desktop sign-in to use: WorkBuddy 5.6
|
|
935
|
+
// and later seal its tokens at rest ({$wbEncrypted: 1, envelope}), which
|
|
936
|
+
// only the app itself opens (plugins#18), so the browser sign-in is the way;
|
|
937
|
+
// else the app isn't signed in.
|
|
938
|
+
function notDesktop(site) {
|
|
939
|
+
try {
|
|
940
|
+
const t = JSON.parse(readFileSync(desktopFile(site), "utf8"))?.auth ?? {}
|
|
941
|
+
if (t.accessToken?.$wbEncrypted || t.refreshToken?.$wbEncrypted)
|
|
942
|
+
return `${site.name} desktop keeps its sign-in encrypted (WorkBuddy 5.6 and later), which magpie can't read; sign in with "${site.name} account (browser)" instead`
|
|
943
|
+
} catch {}
|
|
944
|
+
return `${site.name} desktop isn't signed in`
|
|
945
|
+
}
|
|
946
|
+
|
|
934
947
|
// desktopSignIn uses the account WorkBuddy desktop is signed in to: nothing
|
|
935
948
|
// is copied (a copied refresh token would be the app's and the plugin's
|
|
936
949
|
// both, and the first to use it would sign the other out); its file is
|
|
@@ -942,7 +955,7 @@ function desktopSignIn(site) {
|
|
|
942
955
|
method: "auto",
|
|
943
956
|
async callback() {
|
|
944
957
|
const d = readDesktop(site)
|
|
945
|
-
if (!d) return { type: "failed", error:
|
|
958
|
+
if (!d) return { type: "failed", error: notDesktop(site) }
|
|
946
959
|
return { type: "success", refresh: "", access: "", expires: 0, source: "desktop", accountId: d.name || site.name, uid: d.uid }
|
|
947
960
|
},
|
|
948
961
|
}
|
|
@@ -957,7 +970,7 @@ const desktopHeld = new Map()
|
|
|
957
970
|
async function current(site, client, auth) {
|
|
958
971
|
if (auth?.source !== "desktop") return fresh(site, client, auth)
|
|
959
972
|
const d = readDesktop(site)
|
|
960
|
-
if (!d) throw new Error(
|
|
973
|
+
if (!d) throw new Error(notDesktop(site))
|
|
961
974
|
const k = site.id + "|" + d.uid
|
|
962
975
|
const h = desktopHeld.get(k)
|
|
963
976
|
const a = await fresh(site, null, h && h.expires >= d.expires ? h : d)
|
|
@@ -1425,4 +1438,4 @@ export const WorkBuddyAuthPlugin = makePlugin(SITES.workbuddy)
|
|
|
1425
1438
|
export const WorkBuddyAIAuthPlugin = makePlugin(SITES["workbuddy-ai"])
|
|
1426
1439
|
|
|
1427
1440
|
// for tests
|
|
1428
|
-
export const _internal = { textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, normalizeToolChoice, fitTools, fitted, renamed, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, freeCredits, creditsOf, fresh, SITES, renewing, renewed, SESSION, attend, turnKey, conversationKey, signatureOf }
|
|
1441
|
+
export const _internal = { notDesktop, textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, normalizeToolChoice, fitTools, fitted, renamed, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, freeCredits, creditsOf, fresh, SITES, renewing, renewed, SESSION, attend, turnKey, conversationKey, signatureOf }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-workbuddy-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
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": "./index.mjs",
|