Skip to content

Commit dc6c848

Browse files
PiquelChipsclaude
andcommitted
fix(sdk): ignore a revocation's body, and refuse an empty request_uri
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b65e993 commit dc6c848

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎packages/auth/src/client.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const tokenResponse = json.object({
9595
refresh_token: json.optional(json.string)
9696
});
9797

98-
const pushedAuthorization = json.object({ request_uri: json.string });
98+
const pushedAuthorization = json.object({ request_uri: json.matching(/^\S+$/, 'a request URI') });
9999

100100
/** Unpadded base64url of `length` random bytes. */
101101
function random(length = RANDOM_BYTES): string {
@@ -232,6 +232,8 @@ export class Client {
232232
const reply = await this.#post(this.issuer.metadata.revocation_endpoint, {
233233
token: refreshToken
234234
});
235+
// A success's body carries nothing and is ignored (RFC 7009 §2.2).
236+
if (reply.status === 200) return;
235237
Client.#read('revocation', reply, (value) => value);
236238
}
237239

‎packages/auth/test/client.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717

1818
const PAR_URL = `${ISSUER}/oauth/par`;
1919
const REQUEST_URI = 'urn:ietf:params:oauth:request_uri:pushed';
20+
const REVOCATION_URL = (DOCUMENT as { revocation_endpoint: string }).revocation_endpoint;
2021
const ID = vector('tokens', 'id-valid');
2122
const PUBLIC: ClientConfig = { clientId: 'notes-web', redirectUri: REDIRECT_URI };
2223

@@ -112,6 +113,17 @@ test('a refused request keeps its OAuth error; any other answer is a network err
112113
assert.deepEqual(await outcome(() => broken.client.refresh('prt_v1_old')), {
113114
error: { code: 'network' }
114115
});
116+
const unpushed = await client({
117+
[PAR_URL]: () => Response.json({ request_uri: '', expires_in: 60 }, { status: 201 })
118+
});
119+
await assert.rejects(unpushed.client.authorize(), { code: 'network' });
120+
});
121+
122+
test('a revocation succeeds on HTTP 200, whatever its body', async () => {
123+
const { client: revoking } = await client({
124+
[REVOCATION_URL]: () => new Response('revoked', { status: 200 })
125+
});
126+
await revoking.revoke('prt_v1_old');
115127
});
116128

117129
test('a login completes with an ID token validated against the pending login', async () => {

0 commit comments

Comments
 (0)