qoder 0.2.25: qoder.com's sign-in sends no redirect_uri, so Qoder.app isn't handed the page (#276)

SITES.qoder asked qoder.com's device page for redirect_uri=qoder-app://,
the desktop app's own scheme (Qoder.app's Info.plist registers qoder and
qoder-app). On a Mac with Qoder.app installed the page's last hop opened
the desktop app instead of staying in the tab, while the plugin polls
openapi.qoder.sh for the device token and needs no callback at all.

Qoder's own clients treat the parameter as optional: Qoder.app's
app.asar adds redirect_uri only when its config has one
(authRedirectUris: stable qoder-app://, canary qoder-canary://), and
Qoder's CLI (@qoder-ai/qodercli 1.1.75, bundle/qodercli.js) builds
/device/selectAccounts from challenge, challenge_method, nonce,
machine_id and client_id alone, then polls /api/v1/deviceToken/poll.
qoder.com now gets the same: no redirect_uri, as qoder-cn already does.

cn.test.mjs's "qoder.com's sign-in is as it was" pinned the bug
(redirect_uri == qoder-app://); it now checks there is none.

Run:
- packages/qoder: HOME=<scratch> bun test: 167 pass, 0 fail.
- Broke it by hand (redirect back to "qoder-app://"): the #276 test in
  cn.test.mjs fails (Expected false, Received true), 11 pass 1 fail.
- Repo root, as CI: TMPDIR=<scratch> HOME=<scratch>/home2 bun test:
  1919 pass, 1 skip, 0 fail across 173 files; bun scripts/check.mjs ok.

Not tried against a real Qoder account here. The reporter (asuan-dev)
says the same one-line change on 0.2.21 signed in three accounts and
left the page on "Sign in success".
This commit is contained in:
yetone
2026-10-21 06:29:29 +08:00
parent 7a74416a4d
commit f5548bd5ca
4 changed files with 16 additions and 5 deletions
+6 -1
View File
@@ -22,6 +22,11 @@ hosts; [its section](#qoder-cn) says what differs.
3. The device token is traded for a job token, and the account's email and
name are read.
The page is asked for no `redirect_uri`, as Qoder's CLI asks for none, so
the sign-in ends in the browser tab even when Qoder.app is installed
(before 0.2.25 it sent the desktop app's `qoder-app://`, which handed the
page to Qoder.app).
**Sign in with Qoder PAT** (and **Sign in with Qoder CN PAT**) skips the
device flow: a Personal Access Token from `<site>/account/integrations` is
posted to `/api/v1/jobToken/exchange` (`personal_token`), which answers a
@@ -178,7 +183,7 @@ Qoder CN's own CLI builds in for its `cn` build (`@qodercn-ai/qoderclicn`
| Accounts: poll, tokens, user info, usage | openapi.qoder.sh | openapi.qoder.com.cn |
| Models and chat | api3.qoder.sh | gateway.qoder.com.cn |
| Device-flow client id | Qoder's desktop client's | Qoder CN's CLI's (production) |
| `redirect_uri` on the sign-in page | `qoder-app://` | none, as the CLI sends |
| `redirect_uri` on the sign-in page | none, as Qoder's CLI sends (since 0.2.25) | none, as the CLI sends |
Qoder CN's CLI chats with the device token itself and never makes a job
token. The plugin asks qoder.cn for a job token first, as it does on
+5 -2
View File
@@ -73,12 +73,15 @@ test("the sign-in page is qoder.cn's, with Qoder CN's CLI client id and no redir
for (const k of ["challenge", "nonce", "machine_id"]) expect(u.searchParams.get(k)).toBeTruthy()
})
test("qoder.com's sign-in is as it was", async () => {
test("qoder.com's sign-in sends no redirect_uri, as Qoder's CLI does, so Qoder.app isn't handed the page (#276)", async () => {
const flow = await (await QoderAuthPlugin({ client: store().client })).auth.methods[0].authorize()
const u = new URL(flow.url)
expect(u.origin + u.pathname).toBe("https://qoder.com/device/selectAccounts")
expect(u.searchParams.get("client_id")).toBe("732aef47-9cf2-46a2-95fe-4cebb5d0d1fa")
expect(u.searchParams.get("redirect_uri")).toBe("qoder-app://")
expect(u.searchParams.get("challenge_method")).toBe("S256")
for (const k of ["challenge", "nonce", "machine_id"]) expect(u.searchParams.get(k)).toBeTruthy()
expect(u.searchParams.has("redirect_uri")).toBe(false)
expect(flow.url).not.toContain("qoder-app")
})
test("the sign-in polls openapi.qoder.com.cn until authorized, then makes a job token there", async () => {
+4 -1
View File
@@ -1504,7 +1504,10 @@ const SITES = {
web: "https://qoder.com",
openapi: "https://openapi.qoder.sh",
api: "https://api3.qoder.sh",
redirect: "qoder-app://",
// none, as Qoder's CLI (@qoder-ai/qodercli 1.1.75) sends: the desktop
// app's qoder-app:// hands the finished page to Qoder.app, when it is
// installed, instead of leaving it in the tab while this polls (#276)
redirect: "",
models: MODELS,
},
"qoder-cn": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-qoder-auth",
"version": "0.2.24",
"version": "0.2.25",
"description": "Qoder subscriptions in OpenCode and magpie: Qoder (qoder.com) and Qoder CN (qoder.cn)",
"type": "module",
"main": "./index.mjs",