@zereight/mcp-gitlab 2.3.12 → 2.3.13-next.166
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/build/oauth-proxy.js +21 -2
- package/package.json +1 -1
package/build/oauth-proxy.js
CHANGED
|
@@ -73,6 +73,25 @@ const GROUP_MEMBERSHIP_CACHE_MAX_SIZE = 1000;
|
|
|
73
73
|
const GROUP_MEMBERSHIP_CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
74
74
|
const GROUP_ACCESS_DENIED_MESSAGE = "Access denied: user is not a member of an allowed group";
|
|
75
75
|
const REFRESH_TOKEN_DISABLED_MESSAGE = "Refresh tokens are disabled on this server (OAUTH_DISABLE_REFRESH_TOKEN); start a new authorization";
|
|
76
|
+
/**
|
|
77
|
+
* Maps a non-OK GitLab /oauth/token response. A rotated, revoked or expired
|
|
78
|
+
* refresh token or authorization code is a 400 invalid_grant, which clients
|
|
79
|
+
* must see as invalid_grant to restart authorization; anything else stays a
|
|
80
|
+
* ServerError.
|
|
81
|
+
*/
|
|
82
|
+
function tokenEndpointError(operation, status, body) {
|
|
83
|
+
let gitlabError;
|
|
84
|
+
try {
|
|
85
|
+
gitlabError = JSON.parse(body)?.error;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
gitlabError = undefined;
|
|
89
|
+
}
|
|
90
|
+
if (status === 400 && gitlabError === "invalid_grant") {
|
|
91
|
+
return new InvalidGrantError(`${operation} rejected by GitLab; start a new authorization`);
|
|
92
|
+
}
|
|
93
|
+
return new ServerError(`${operation} failed: ${status}`);
|
|
94
|
+
}
|
|
76
95
|
function singleQueryParam(value) {
|
|
77
96
|
return typeof value === "string" ? value : undefined;
|
|
78
97
|
}
|
|
@@ -515,7 +534,7 @@ class GitLabOAuthServerProvider {
|
|
|
515
534
|
if (!response.ok) {
|
|
516
535
|
const body = await response.text();
|
|
517
536
|
logger.error(`Token exchange failed (${response.status}): ${body}`);
|
|
518
|
-
throw
|
|
537
|
+
throw tokenEndpointError("Token exchange", response.status, body);
|
|
519
538
|
}
|
|
520
539
|
const data = await response.json();
|
|
521
540
|
tokens = OAuthTokensSchema.parse(data);
|
|
@@ -629,7 +648,7 @@ class GitLabOAuthServerProvider {
|
|
|
629
648
|
if (!response.ok) {
|
|
630
649
|
const body = await response.text();
|
|
631
650
|
logger.error(`Token refresh failed (${response.status}): ${body}`);
|
|
632
|
-
throw
|
|
651
|
+
throw tokenEndpointError("Token refresh", response.status, body);
|
|
633
652
|
}
|
|
634
653
|
const data = await response.json();
|
|
635
654
|
const tokens = OAuthTokensSchema.parse(data);
|
package/package.json
CHANGED