mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 13:53:02 -07:00
Refactor: Migrate CLI appEvents to Core coreEvents (#15737)
This commit is contained in:
@@ -42,11 +42,7 @@ import type {
|
||||
OAuthTokenResponse,
|
||||
OAuthClientRegistrationResponse,
|
||||
} from './oauth-provider.js';
|
||||
import {
|
||||
MCPOAuthProvider,
|
||||
OAUTH_DISPLAY_MESSAGE_EVENT,
|
||||
} from './oauth-provider.js';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import { MCPOAuthProvider } from './oauth-provider.js';
|
||||
import type { OAuthToken } from './token-storage/types.js';
|
||||
import { MCPOAuthTokenStorage } from './oauth-token-storage.js';
|
||||
import {
|
||||
@@ -1195,20 +1191,17 @@ describe('MCPOAuthProvider', () => {
|
||||
);
|
||||
|
||||
const authProvider = new MCPOAuthProvider();
|
||||
const eventEmitter = new EventEmitter();
|
||||
const messagePromise = new Promise<string>((resolve) => {
|
||||
eventEmitter.on(OAUTH_DISPLAY_MESSAGE_EVENT, resolve);
|
||||
});
|
||||
|
||||
await authProvider.authenticate(
|
||||
'production-server',
|
||||
mockConfig,
|
||||
undefined,
|
||||
eventEmitter,
|
||||
);
|
||||
|
||||
const message = await messagePromise;
|
||||
expect(message).toContain('production-server');
|
||||
expect(coreEvents.emitFeedback).toHaveBeenCalledWith(
|
||||
'info',
|
||||
expect.stringContaining('production-server'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import * as http from 'node:http';
|
||||
import * as crypto from 'node:crypto';
|
||||
import type * as net from 'node:net';
|
||||
import { URL } from 'node:url';
|
||||
import type { EventEmitter } from 'node:events';
|
||||
import { openBrowserSecurely } from '../utils/secure-browser-launcher.js';
|
||||
import type { OAuthToken } from './token-storage/types.js';
|
||||
import { MCPOAuthTokenStorage } from './oauth-token-storage.js';
|
||||
@@ -744,15 +743,10 @@ export class MCPOAuthProvider {
|
||||
serverName: string,
|
||||
config: MCPOAuthConfig,
|
||||
mcpServerUrl?: string,
|
||||
events?: EventEmitter,
|
||||
): Promise<OAuthToken> {
|
||||
// Helper function to display messages through handler or fallback to console.log
|
||||
const displayMessage = (message: string) => {
|
||||
if (events) {
|
||||
events.emit(OAUTH_DISPLAY_MESSAGE_EVENT, message);
|
||||
} else {
|
||||
debugLogger.log(message);
|
||||
}
|
||||
coreEvents.emitFeedback('info', message);
|
||||
};
|
||||
|
||||
// If no authorization URL is provided, try to discover OAuth configuration
|
||||
|
||||
Reference in New Issue
Block a user