diff --git a/packages/tabbit/README.md b/packages/tabbit/README.md index 6f464e4..3927616 100644 --- a/packages/tabbit/README.md +++ b/packages/tabbit/README.md @@ -57,11 +57,12 @@ refuses it, `web.tabbit.ai` is asked once, and the site that accepts it serves that token from then on (a token both refuse is an expired sign-in, as before). A `web.tabbit.com` token never asks `web.tabbit.ai` anything. -> **International site, chat turns:** as of 2026-11-07, `web.tabbit.ai` -> answers a turn's `runs` call with `429`, code `492` ("Welcome to Tabbit -> Browser…"), a gate the web app passes from inside the browser (#833). -> Sign-in, the catalog, usage and the check-in work there; turns pass that -> `429` through until the gate is solved. +> **International site, chat turns:** `web.tabbit.ai` answers a turn's +> `runs` call with `429`, code `492` ("Welcome to Tabbit Browser...") unless +> the request carries a `unique-uuid` header — the browser sends a fresh +> uuid on every API call, and the gate accepts any well-formed one (a +> net-export capture of Tabbit Browser's own traffic showed the header on +> `runs`, `join` and `usage`). The plugin sends one per call (#834). There is no refresh endpoint. When the token runs out (7 days), magpie shows the account as needing a sign-in again and the first method takes one more diff --git a/packages/tabbit/package.json b/packages/tabbit/package.json index c2b6d24..5557760 100644 --- a/packages/tabbit/package.json +++ b/packages/tabbit/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-tabbit-auth", - "version": "0.1.1", + "version": "0.1.2", "description": "Tabbit (web.tabbit.com and web.tabbit.ai) as a magpie / OpenCode provider: live model catalog, cookie sign-in, chat completions, cycle usage and the daily check-in", "type": "module", "main": "./opencode.mjs", diff --git a/packages/tabbit/src/api.mjs b/packages/tabbit/src/api.mjs index 34475da..590473d 100644 --- a/packages/tabbit/src/api.mjs +++ b/packages/tabbit/src/api.mjs @@ -158,6 +158,12 @@ function headersFor(creds, site, extra) { cookie: creds.header, accept: "application/json", "user-agent": UA, + // web.tabbit.ai's browser sign-in gate (429 code 492 "Welcome to Tabbit + // Browser") refuses a turn whose request carries no `unique-uuid`: the + // browser sends a fresh uuid on every API call, and the gate accepts any + // well-formed one. Measured against a live signed-in session on .ai; + // .com ignores the header. + "unique-uuid": crypto.randomUUID(), origin: site, referer: `${site}/newtab`, ...extra, diff --git a/packages/tabbit/tests/unique-uuid.test.mjs b/packages/tabbit/tests/unique-uuid.test.mjs new file mode 100644 index 0000000..f6490ae --- /dev/null +++ b/packages/tabbit/tests/unique-uuid.test.mjs @@ -0,0 +1,19 @@ +import test from "node:test" +import assert from "node:assert/strict" +import { runTurn } from "../src/api.mjs" + +const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/ + +for (const site of ["https://web.tabbit.ai", "https://web.tabbit.com"]) { + test(`runs on ${site} carries unique-uuid`, async () => { + const seen = [], original = globalThis.fetch + globalThis.fetch = async (input, init = {}) => { seen.push(new Headers(init.headers ?? {})); return Response.json({ run_id: "r", status: "QUEUED" }) } + try { + const creds = { token: "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ1LTEifQ.sig", header: "token=[REDACTED_VALUE]", site } + await runTurn(creds, "room-1", { content: "hi", model: "Default" }) + await runTurn(creds, "room-1", { content: "hi", model: "Default" }) + assert.match(seen[0].get("unique-uuid") ?? "", UUID) + assert.notEqual(seen[0].get("unique-uuid"), seen[1].get("unique-uuid")) + } finally { globalThis.fetch = original } + }) +}