Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(oauth): cut off a revoked client's access tokens at introspection and on its own refresh revoke, and realign consent tests to the grant groups

nirholas2763cd6842ea
diff --git a/api/_lib/auth.js b/api/_lib/auth.js
index 7f1252be5..bf1e19b0e 100644
--- a/api/_lib/auth.js
+++ b/api/_lib/auth.js
@@ -115,6 +115,13 @@ export async function revokeRefreshToken(secret, clientId) {
where token_hash = ${hash} and client_id = ${clientId} and revoked_at is null
returning id, user_id`;
if (row) {
+ // The client ended its own grant (RFC 7009): the access tokens already in
+ // flight for this user and client stop with it, same as Connected apps.
+ await sql`
+ insert into oauth_client_revocations (user_id, client_id, revoked_at)
+ values (${row.user_id}, ${clientId}, now())
+ on conflict (user_id, client_id) do update set revoked_at = excluded.revoked_at
+ `;
logAudit({
userId: row.user_id,
action: 'revoke_oauth_token',
@@ -292,7 +299,7 @@ export function extractBearer(req) {
// Access tokens are stateless JWTs, so revoking a connected app also records a
// cutoff per (user, client). A token issued at or before the cutoff is dead on
// its next use; a token minted after the person re-authorizes the app is not.
-async function isGrantRevoked(payload) {
+export async function oauthGrantRevoked(payload) {
const rows = await sql`
select 1 from oauth_client_revocations
where user_id = ${payload.sub} and client_id = ${payload.client_id}
@@ -367,7 +374,7 @@ export async function authenticateBearer(token, { audience, ip } = {}) {
// token_use prevents a future token type (e.g. an id/refresh JWT) from
// being replayed against resource endpoints.
if (payload.token_use !== 'access') return null;
- if (payload.client_id && await isGrantRevoked(payload)) return null;
+ if (payload.client_id && await oauthGrantRevoked(payload)) return null;
return {
userId: payload.sub,
scope: payload.scope || '',
diff --git a/api/oauth/[action].js b/api/oauth/[action].js
index dce8c574f..53c44ff38 100644
--- a/api/oauth/[action].js
+++ b/api/oauth/[action].js
@@ -6,7 +6,7 @@ import { sql } from '../_lib/db.js';
import {
getSessionUser, csrfTokenFor, verifyCsrfToken, isSameSiteOrigin,
mintAccessToken, issueRefreshToken, rotateRefreshToken,
- revokeRefreshToken, verifyAccessToken, revokeClientGrant,
+ revokeRefreshToken, verifyAccessToken, revokeClientGrant, oauthGrantRevoked,
} from '../_lib/auth.js';
import { randomToken, sha256, sha256Base64Url, constantTimeEquals } from '../_lib/crypto.js';
import { cors, method, wrap, error, redirect, readForm, readJson, json, rateLimited } from '../_lib/http.js';
@@ -490,6 +490,7 @@ async function handleIntrospect(req, res) {
try {
const payload = await verifyAccessToken(token, { audience: allMcpAudiences() });
if (payload.client_id && payload.client_id !== clientId) return json(res, 200, { active: false });
+ if (payload.client_id && await oauthGrantRevoked(payload)) return json(res, 200, { active: false });
return json(res, 200, { active: true, scope: payload.scope, client_id: payload.client_id, sub: payload.sub, aud: payload.aud, iss: payload.iss, exp: payload.exp, iat: payload.iat, token_type: 'Bearer' });
} catch {
const h = await sha256(token);
diff --git a/data/changelog.json b/data/changelog.json
index cb00dd65f..d1c7823e6 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,16 @@
{
"$comment": "Curated changelog entries for three.ws, the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security, desktop (desktop entries become the desktop app's release notes). `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-10-23",
+ "title": "Revoking a connected app now stops it everywhere",
+ "summary": "When Claude, ChatGPT or any MCP client ends its own grant, or you press Revoke in Connected apps, its access tokens stop on the next request and the token introspection endpoint reports them inactive. Other clients on your account stay connected. The consent screen tests now pin the Read, Manage, Trade, Spend and Launch groups.",
+ "tags": [
+ "fix",
+ "security"
+ ],
+ "link": "/dashboard/settings#connected-apps"
+ },
{
"date": "2026-10-23",
"title": "Pay any paid endpoint over MPP on Solana, and sell a skill on four rails from one price",
@@ -24,7 +34,9 @@
"date": "2026-10-23",
"title": "Backtests now prove they are free of look-ahead and can be repeated",
"summary": "Every strategy backtest replays its entry gate with the future removed and reports any decision that changed, pins the exact dataset it ran on with a content hash, and marks older unpinned results as unreproducible. A new canary job checks each price and candle source against a known value every 30 minutes and tries the healthy ones first.",
- "tags": ["feature"],
+ "tags": [
+ "feature"
+ ],
"link": "/strategies"
},
{
@@ -40,7 +52,9 @@
"date": "2026-10-23",
"title": "Creator-fee payouts: register a wallet and see every distribution",
"summary": "Your share of each claimed creator fee now has a record and a destination. Register a payout wallet by signing with it and confirming with a step-up (a change waits 48 hours), then follow what is sent, pending or held and why on the new payouts page, and export every distribution as CSV. Sending stays off until payouts are switched on, and shares are recorded and held until then.",
- "tags": ["feature"],
+ "tags": [
+ "feature"
+ ],
"link": "/creator/payouts"
},
{
diff --git a/docs/mcp.md b/docs/mcp.md
index 0f35ffa9a..0ec8784ec 100644
--- a/docs/mcp.md
+++ b/docs/mcp.md
@@ -255,7 +255,7 @@ A connector that runs in a vendor's cloud has no browser on your machine and no
`wallet:write` implies `wallet:trade` and `wallet:launch`, so a token minted before the split keeps every power it had. A client that registered only `wallet:trade` can trade but every route that moves funds out answers `insufficient_scope`.
- **PKCE.** `code_challenge_method=S256` is required on every authorization request.
-- **Seeing and revoking.** Every connected app is listed at [Settings, Connected apps](https://three.ws/dashboard/settings#connected-apps) with when it was authorized and last used. `GET /api/oauth/grants` returns the same list and `DELETE /api/oauth/grants?client_id=...` revokes one app (browser session only, so a token can never list or revoke other apps). Revocation is effective on the app's next request: its refresh tokens are revoked and a cutoff is recorded that every access token issued before it fails against, so there is no one-hour tail. Other apps on the account are untouched: revoking Claude leaves ChatGPT connected, on its access token and its refresh token alike. The app can ask you again; a token issued after you approve it anew works.
+- **Seeing and revoking.** Every connected app is listed at [Settings, Connected apps](https://three.ws/dashboard/settings#connected-apps) with when it was authorized and last used. `GET /api/oauth/grants` returns the same list and `DELETE /api/oauth/grants?client_id=...` revokes one app (browser session only, so a token can never list or revoke other apps). Revocation is effective on the app's next request: its refresh tokens are revoked and a cutoff is recorded that every access token issued before it fails against, so there is no one-hour tail. The same cutoff applies when the app revokes its own refresh token (RFC 7009), and `POST /oauth/introspect` answers `active: false` for any access token older than it. Other apps on the account are untouched: revoking Claude leaves ChatGPT connected, on its access token and its refresh token alike. The app can ask you again; a token issued after you approve it anew works.
- **Sign-in methods.** [Settings, Sign-in methods](https://three.ws/dashboard/settings#sign-in-methods) lists every way into the account and lets you link or unlink Google. Unlinking needs a fresh proof (the account password, or signing in to Google once more), and an account is never left with no way in. The flow itself is documented in [Authentication, Sign in with Google](/docs/authentication#sign-in-with-google).
The end-to-end proof is `tests/e2e/oauth-cloud-connector.spec.js`: it registers "Grok Bot" with an external redirect URI, runs the PKCE flow as the QA account, calls `tools/list` on `/api/mcp`, revokes from Settings and watches the next call fail with `401`. `tests/oauth-endpoints.test.js` covers the grant groups (what the screen lists, what an unticked group removes from the code) and the two-client case (both connected, one revoked, the other still working on access and refresh tokens), and `tests/api/google-signin.test.js` covers the Google round trip.
diff --git a/tests/api/oauth-authorize.test.js b/tests/api/oauth-authorize.test.js
index d591467c7..7f44ab18c 100644
--- a/tests/api/oauth-authorize.test.js
+++ b/tests/api/oauth-authorize.test.js
@@ -292,7 +292,7 @@ describe('GET /api/oauth/authorize — consent page render', () => {
const { res, status, body } = await invoke({ url: `/api/oauth/authorize?${VALID_QS}` });
expect(status).toBe(200);
expect(res.headers['content-type']).toMatch(/text\/html/);
- expect(body).toContain('<b>Test Client</b> wants to connect to your three.ws account');
+ expect(body).toContain('Authorize <b>Test Client</b>');
expect(body).toContain('name="csrf"');
// Original PKCE params are preserved as hidden inputs for POST submit.
expect(body).toContain('name="code_challenge"');
diff --git a/tests/oauth-endpoints.test.js b/tests/oauth-endpoints.test.js
index e7421064c..354977c56 100644
--- a/tests/oauth-endpoints.test.js
+++ b/tests/oauth-endpoints.test.js
@@ -128,7 +128,7 @@ const sqlMock = vi.fn(async (strings, ...values) => {
const rows = live.filter((r) => r.client_id === clientId);
return {
client_id: clientId, name: c.name, client_uri: c.client_uri ?? null, logo_uri: null, software_id: null, software_version: null,
- authorized_at: rows[0].created_at ?? null, last_used_at: rows.map((r) => r.last_used_at).filter(Boolean).sort().pop() ?? null,
+ authorized_at: rows[0].created_at ?? null, last_used_at: rows.map((r) => r.last_used_at ?? r.created_at).filter(Boolean).sort().pop() ?? null,
scopes: rows.map((r) => r.scope).join(' '),
};
});
@@ -278,8 +278,8 @@ describe('GET /oauth/authorize', () => {
const res = await call('authorize', { query: authorizeQuery({ scope: 'memory:write' }) });
expect(res.statusCode).toBe(200);
expect(res.getHeader('content-type')).toContain('text/html');
- expect(res.body).toContain('See your avatars');
- expect(res.body).toContain('See your name and email');
+ expect(res.body).toContain('<li>Read your avatars</li>');
+ expect(res.body).toContain('<li>See your name and email</li>');
expect(res.body).not.toContain('Save and erase');
});
@@ -629,7 +629,8 @@ describe('POST /oauth/register for a cloud connector', () => {
const consent = await call('authorize', { query: { ...authorizeQuery({ client_id: body.client_id, redirect_uri: GROK.redirect_uris[0] }) } });
expect(consent.statusCode).toBe(200);
- expect(consent.body).toContain('<b>Grok Bot</b> wants to connect to your three.ws account');
+ expect(consent.body).toContain('Authorize <b>Grok Bot</b>');
+ expect(consent.body).toContain('Site: grok.com');
});
it.each([
@@ -666,34 +667,34 @@ describe('consent screen for a cloud connector', () => {
...overrides,
});
- it('names the client, its site host and where the code goes, and says it can never spend', async () => {
- grok();
+ it('names the client and its site host, flags a self-registered app, and says it can never spend', async () => {
+ grok({ scope: 'avatars:read profile' });
const res = await call('authorize', { query: authorizeQuery() });
expect(res.statusCode).toBe(200);
- expect(res.body).toContain('<b>Grok Bot</b> wants to connect');
- expect(res.body).toContain('<dd data-fact="client-host">grok.com</dd>');
- expect(res.body).toContain('<dd data-fact="return-host">client.example</dd>');
- expect(res.body).toContain('three.ws has not verified this app');
- expect(res.body).toContain('It can never spend from your wallet.');
- expect(res.body).toContain('<li>See your avatars</li>');
- expect(res.body).toContain('<li>See your name and email address</li>');
+ expect(res.body).toContain('Authorize <b>Grok Bot</b>');
+ expect(res.body).toContain('Site: grok.com');
+ expect(res.body).toContain('This app registered itself.');
+ expect(res.body).toContain('can never spend from a wallet');
+ expect(res.body).toContain('<li>Read your avatars</li>');
+ expect(res.body).toContain('<li>See your name and email</li>');
});
- it('keeps the spend scope out of the list and behind an unticked box', async () => {
+ it('offers spend as its own unlocked, ticked-by-default group that lists what still asks first', async () => {
grok();
const res = await call('authorize', { query: authorizeQuery() });
- const list = res.body.match(/<ul data-scopes>(.*?)<\/ul>/)[1];
- expect(list).not.toContain('Spend USDC');
- expect(list).toContain('See your agent wallet balance and spending caps');
- expect(res.body).toMatch(/<input type="checkbox" id="allow-spend" name="allow_spend" value="yes">/);
- expect(res.body).not.toMatch(/id="allow-spend"[^>]*checked/);
+ expect(res.body).toContain('is asking to spend from your agent wallet');
+ const spend = res.body.match(/<label class="group">(?:(?!<\/label>).)*name="grant_spend"(?:(?!<\/label>).)*<\/label>/s)[0];
+ expect(spend).toContain('<li>Send and spend USDC from your agent wallet, within your caps</li>');
+ expect(spend).toContain('Still asks you first:');
+ expect(spend).not.toContain('disabled');
+ expect(res.body).toMatch(/name="grant_read" value="on" checked disabled/);
});
- it('shows no spend box when the client never asked to spend', async () => {
+ it('shows no spend group when the client never asked to spend', async () => {
grok({ scope: 'avatars:read profile' });
const res = await call('authorize', { query: authorizeQuery() });
- expect(res.body).not.toContain('allow_spend');
- expect(res.body).toContain('It can never spend from your wallet.');
+ expect(res.body).not.toContain('grant_spend');
+ expect(res.body).toContain('can never spend from a wallet');
});
it('escapes a hostile client name everywhere it appears', async () => {
@@ -703,15 +704,15 @@ describe('consent screen for a cloud connector', () => {
expect(res.body).toContain('&lt;img src=x onerror=alert(1)&gt;');
});
- it('grants wallet:read, not wallet:write, when the person leaves the box unticked', async () => {
+ it('drops wallet:write from the code when the person unticks the Spend group', async () => {
grok();
- await approve({ scope: 'avatars:read profile wallet:write' });
- expect(db.codes[0].scope.split(' ').sort()).toEqual(['avatars:read', 'profile', 'wallet:read']);
+ await approve({ scope: 'avatars:read profile wallet:write', grant_read: 'on' });
+ expect(db.codes[0].scope.split(' ').sort()).toEqual(['avatars:read', 'profile']);
});
- it('grants wallet:write only when the person ticks the box', async () => {
+ it('grants wallet:write only when the person ticks the Spend group', async () => {
grok();
- await approve({ scope: 'avatars:read profile wallet:write', allow_spend: 'yes' });
+ await approve({ scope: 'avatars:read profile wallet:write', grant_read: 'on', grant_spend: 'on' });
expect(db.codes[0].scope.split(' ')).toContain('wallet:write');
});
});