diff --git a/packages/qoder/README.md b/packages/qoder/README.md index 98ae11a..3d7728f 100644 --- a/packages/qoder/README.md +++ b/packages/qoder/README.md @@ -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 `/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 diff --git a/packages/qoder/cn.test.mjs b/packages/qoder/cn.test.mjs index 51a433a..a11ede6 100644 --- a/packages/qoder/cn.test.mjs +++ b/packages/qoder/cn.test.mjs @@ -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 () => { diff --git a/packages/qoder/index.mjs b/packages/qoder/index.mjs index fb0e101..75284c6 100644 --- a/packages/qoder/index.mjs +++ b/packages/qoder/index.mjs @@ -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": { diff --git a/packages/qoder/package.json b/packages/qoder/package.json index b950d5b..995d3e3 100644 --- a/packages/qoder/package.json +++ b/packages/qoder/package.json @@ -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",