11import pkceChallenge from "pkce-challenge" ;
22import { LATEST_PROTOCOL_VERSION } from "../types.js" ;
3- import type { OAuthClientMetadata , OAuthClientInformation , OAuthTokens , OAuthMetadata } from "../shared/auth.js" ;
4- import { OAuthClientInformationSchema , OAuthMetadataSchema , OAuthTokensSchema } from "../shared/auth.js" ;
3+ import type { OAuthClientMetadata , OAuthClientInformation , OAuthTokens , OAuthMetadata , OAuthClientInformationFull } from "../shared/auth.js" ;
4+ import { OAuthClientInformationFullSchema , OAuthMetadataSchema , OAuthTokensSchema } from "../shared/auth.js" ;
55
66/**
77 * Implements an end-to-end OAuth client to be used with one MCP server.
@@ -36,7 +36,7 @@ export interface OAuthClientProvider {
3636 * This method is not required to be implemented if client information is
3737 * statically known (e.g., pre-registered).
3838 */
39- saveClientInformation ?( clientInformation : OAuthClientInformation ) : void | Promise < void > ;
39+ saveClientInformation ?( clientInformation : OAuthClientInformationFull ) : void | Promise < void > ;
4040
4141 /**
4242 * Loads any existing OAuth tokens for the current session, or returns
@@ -98,12 +98,13 @@ export async function auth(
9898 throw new Error ( "OAuth client information must be saveable for dynamic registration" ) ;
9999 }
100100
101- clientInformation = await registerClient ( serverUrl , {
101+ const fullInformation = await registerClient ( serverUrl , {
102102 metadata,
103103 clientMetadata : provider . clientMetadata ,
104104 } ) ;
105105
106- await provider . saveClientInformation ( clientInformation ) ;
106+ await provider . saveClientInformation ( fullInformation ) ;
107+ clientInformation = fullInformation ;
107108 }
108109
109110 // Exchange authorization code for tokens
@@ -371,7 +372,7 @@ export async function registerClient(
371372 metadata ?: OAuthMetadata ;
372373 clientMetadata : OAuthClientMetadata ;
373374 } ,
374- ) : Promise < OAuthClientInformation > {
375+ ) : Promise < OAuthClientInformationFull > {
375376 let registrationUrl : URL ;
376377
377378 if ( metadata ) {
@@ -396,5 +397,5 @@ export async function registerClient(
396397 throw new Error ( `Dynamic client registration failed: HTTP ${ response . status } ` ) ;
397398 }
398399
399- return OAuthClientInformationSchema . parse ( await response . json ( ) ) ;
400+ return OAuthClientInformationFullSchema . parse ( await response . json ( ) ) ;
400401}
0 commit comments