@zereight/mcp-gitlab 2.0.28 → 2.0.32

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.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as fs from "fs";
2
+ import * as os from "os";
2
3
  import * as path from "path";
3
4
  import * as http from "http";
4
5
  import * as net from "net";
@@ -82,7 +83,7 @@ export class GitLabOAuth {
82
83
  constructor(config) {
83
84
  this.config = config;
84
85
  this.tokenStoragePath =
85
- config.tokenStoragePath || path.join(process.env.HOME || "", ".gitlab-mcp-token.json");
86
+ config.tokenStoragePath || path.join(os.homedir(), ".gitlab-mcp-token.json");
86
87
  }
87
88
  /**
88
89
  * Get the authorization URL for OAuth flow
@@ -505,9 +506,11 @@ export class GitLabOAuth {
505
506
  }
506
507
  }
507
508
  /**
508
- * Initialize OAuth authentication for GitLab MCP server
509
+ * Create and initialize a GitLabOAuth client.
510
+ * Performs initial authentication (triggers browser flow if needed).
511
+ * Returns the client instance and the initial access token.
509
512
  */
510
- export async function initializeOAuth(gitlabUrl = "https://gitlab.com") {
513
+ export async function initializeOAuthClient(gitlabUrl = "https://gitlab.com") {
511
514
  const clientId = process.env.GITLAB_OAUTH_CLIENT_ID;
512
515
  const clientSecret = process.env.GITLAB_OAUTH_CLIENT_SECRET;
513
516
  const redirectUri = process.env.GITLAB_OAUTH_REDIRECT_URI || "http://127.0.0.1:8888/callback";
@@ -523,5 +526,14 @@ export async function initializeOAuth(gitlabUrl = "https://gitlab.com") {
523
526
  scopes: ["api"],
524
527
  tokenStoragePath,
525
528
  });
526
- return await oauth.getAccessToken();
529
+ // Single call: triggers browser flow if needed, or reads cached token
530
+ const accessToken = await oauth.getAccessToken();
531
+ return { client: oauth, accessToken };
532
+ }
533
+ /**
534
+ * Initialize OAuth authentication for GitLab MCP server
535
+ */
536
+ export async function initializeOAuth(gitlabUrl = "https://gitlab.com") {
537
+ const { accessToken } = await initializeOAuthClient(gitlabUrl);
538
+ return accessToken;
527
539
  }