Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/client/src/client/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,10 @@ export async function executeTokenRequest(
applyClientAuthentication(authMethod, clientInformation as OAuthClientInformation, headers, tokenRequestParams);
}

// Ensure Content-Type is always form-urlencoded for the token endpoint (OAuth 2.1 §3.2).
// Some addClientAuthentication implementations may have inadvertently set a different value.
headers.set('Content-Type', 'application/x-www-form-urlencoded');

const response = await (fetchFn ?? fetch)(tokenUrl, {
method: 'POST',
headers,
Expand Down
14 changes: 12 additions & 2 deletions packages/core/src/types/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,18 @@ export const ResultSchema = z.looseObject({

/**
* A uniquely identifying ID for a request in JSON-RPC.
*/
export const RequestIdSchema = z.union([z.string(), z.number().int()]);
* Rejects integers outside Number.MAX_SAFE_INTEGER to prevent JavaScript
* Map/Object key precision loss that causes server hangs (Issue #1765).
*/
export const RequestIdSchema = z.union([
z.string(),
z
.number()
.int()
.refine((n) => Math.abs(n) <= Number.MAX_SAFE_INTEGER, {
message: `Request ID must be a safe integer (|id| ≤ ${Number.MAX_SAFE_INTEGER})`
})
]);

/**
* A request that expects a response.
Expand Down
Loading