File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
configure-mcp-server/src/configure/client
mcp-server-utils/src/auth Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import { RemoteMcpTargets } from '@gleanwork/mcp-server-utils/util';
1212import { isOAuthEnabled } from '../../common/env.js' ;
1313
1414import connectMcpPackageJson from '@gleanwork/connect-mcp-server/package.json' with { type : 'json' } ;
15- let connectMcpServerVersion = connectMcpPackageJson . version ;
15+ const connectMcpServerVersion = connectMcpPackageJson . version ;
1616
1717export interface MCPConfigPath {
1818 configDir : string ;
Original file line number Diff line number Diff line change @@ -546,21 +546,28 @@ async function authorize(config: GleanOAuthConfig): Promise<Tokens | null> {
546546 ) . catch ( ( e ) => {
547547 error ( 'prompting user for verification page' , e ) ;
548548 } ) ;
549- const tokenResponse = await tokenPoller ;
549+ const polledTokenResponse = await tokenPoller ;
550550
551551 // Clean up the readline interface now that we have the token
552552 abortController . abort ( ) ;
553553
554554 if ( cause !== undefined ) {
555555 throw cause ;
556556 }
557+
558+ // tokenResponse is void | TokenResponse because of the catch handler
559+ // attached to pollForToken, which sets cause and resolves to void. But
560+ // right above here we throw if cause !== undefined so we can guarantee
561+ // tokenResponse is TokenResponse and not void.
562+ const tokenResponse = polledTokenResponse as TokenResponse ;
563+
557564 if ( tokenResponse . refresh_token === undefined ) {
558565 throw new AuthError (
559566 `Your OAuth Authorization Server issued an access token but not a refresh token. Please configure your OAuth application with id: ${ config . clientId } to issue refresh tokens.` ,
560567 { code : AuthErrorCode . RefreshTokenNotIssued } ,
561568 ) ;
562569 }
563- return Tokens . buildFromTokenResponse ( tokenResponse as TokenResponse ) ;
570+ return Tokens . buildFromTokenResponse ( tokenResponse ) ;
564571 } catch ( cause : any ) {
565572 // Clean up the readline interface on error as well
566573 abortController . abort ( ) ;
You can’t perform that action at this time.
0 commit comments