diff --git a/lib/msal-browser/src/broker/nativeBroker/NativeRequest.ts b/lib/msal-browser/src/broker/nativeBroker/NativeRequest.ts index d85e977646..8402d57805 100644 --- a/lib/msal-browser/src/broker/nativeBroker/NativeRequest.ts +++ b/lib/msal-browser/src/broker/nativeBroker/NativeRequest.ts @@ -32,6 +32,7 @@ export type NativeTokenRequest = { extraParameters?: StringDict; storeInCache?: StoreInCache; // Object of booleans indicating whether to store tokens in the cache or not (default is true) signPopToken?: boolean; // Set to true only if token request deos not contain a PoP keyId + embeddedClientId?: string; }; /** diff --git a/lib/msal-browser/src/interaction_client/NativeInteractionClient.ts b/lib/msal-browser/src/interaction_client/NativeInteractionClient.ts index 58f8e06f4f..1f72671ed0 100644 --- a/lib/msal-browser/src/interaction_client/NativeInteractionClient.ts +++ b/lib/msal-browser/src/interaction_client/NativeInteractionClient.ts @@ -1043,18 +1043,36 @@ export class NativeInteractionClient extends BaseInteractionClient { return; } - if ( + const hasExtraBrokerParams = + request.extraParameters && request.extraParameters.hasOwnProperty( AADServerParamKeys.BROKER_CLIENT_ID ) && request.extraParameters.hasOwnProperty( AADServerParamKeys.BROKER_REDIRECT_URI ) && - request.extraParameters.hasOwnProperty(AADServerParamKeys.CLIENT_ID) - ) { - const child_client_id = - request.extraParameters[AADServerParamKeys.CLIENT_ID]; - const child_redirect_uri = request.redirectUri; + request.extraParameters.hasOwnProperty( + AADServerParamKeys.CLIENT_ID + ); + + if (!request.embeddedClientId && !hasExtraBrokerParams) { + return; + } + + const child_client_id = + request.extraParameters[AADServerParamKeys.CLIENT_ID]; + const child_redirect_uri = request.redirectUri; + + if (request.embeddedClientId) { + request.extraParameters = { + [AADServerParamKeys.BROKER_CLIENT_ID]: + this.config.auth.clientId, + [AADServerParamKeys.BROKER_REDIRECT_URI]: + this.config.auth.redirectUri, + child_client_id, + child_redirect_uri, + }; + } else if (hasExtraBrokerParams) { const brk_redirect_uri = request.extraParameters[AADServerParamKeys.BROKER_REDIRECT_URI]; request.extraParameters = { @@ -1063,5 +1081,13 @@ export class NativeInteractionClient extends BaseInteractionClient { }; request.redirectUri = brk_redirect_uri; } + + this.performanceClient?.addFields( + { + embeddedClientId: child_client_id, + embeddedRedirectUri: child_redirect_uri, + }, + request.correlationId + ); } }