@context-engine-bridge/context-engine-mcp-bridge 0.0.86 → 0.0.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/oauthHandler.js +18 -20
package/package.json
CHANGED
package/src/oauthHandler.js
CHANGED
|
@@ -560,8 +560,7 @@ export function handleOAuthToken(req, res) {
|
|
|
560
560
|
const code = data.get("code");
|
|
561
561
|
const redirectUri = data.get("redirect_uri");
|
|
562
562
|
const clientId = data.get("client_id");
|
|
563
|
-
|
|
564
|
-
data.get("code_verifier");
|
|
563
|
+
const codeVerifier = data.get("code_verifier");
|
|
565
564
|
const grantType = data.get("grant_type");
|
|
566
565
|
|
|
567
566
|
res.setHeader("Content-Type", "application/json");
|
|
@@ -605,24 +604,23 @@ export function handleOAuthToken(req, res) {
|
|
|
605
604
|
return;
|
|
606
605
|
}
|
|
607
606
|
|
|
608
|
-
//
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
// }
|
|
607
|
+
// PKCE validation (RFC 7636)
|
|
608
|
+
if (pendingData.codeChallenge && pendingData.codeChallengeMethod === "S256") {
|
|
609
|
+
if (!codeVerifier) {
|
|
610
|
+
pendingCodes.delete(code);
|
|
611
|
+
res.statusCode = 400;
|
|
612
|
+
res.end(JSON.stringify({ error: "invalid_grant", error_description: "code_verifier required for PKCE" }));
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
const crypto = await import("node:crypto");
|
|
616
|
+
const expectedChallenge = crypto.createHash("sha256").update(codeVerifier).digest("base64url");
|
|
617
|
+
if (expectedChallenge !== pendingData.codeChallenge) {
|
|
618
|
+
pendingCodes.delete(code);
|
|
619
|
+
res.statusCode = 400;
|
|
620
|
+
res.end(JSON.stringify({ error: "invalid_grant", error_description: "code_verifier validation failed" }));
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
626
624
|
|
|
627
625
|
// Clean up expired tokens periodically to prevent unbounded growth
|
|
628
626
|
cleanupExpiredTokens();
|