Skip to content

Conversation

@yongdiw
Copy link
Contributor

@yongdiw yongdiw commented Aug 6, 2025

This pull request adds support for passing extra query parameters (dc and slice) to custom authentication API requests in the MSAL browser library. This enhancement allows clients to specify datacenter and slice information in API calls, improving flexibility and routing capabilities. The changes include updates to configuration types, API client constructors, URL building utilities, and comprehensive tests to ensure correct behavior.

Support for extra query parameters in custom authentication:

  • Added extraQueryParameters (with keys dc and slice) to CustomAuthOptions and associated types, enabling clients to specify additional query parameters for custom authentication requests.
  • Updated constructors for BaseApiClient and CustomAuthApiClient to accept and propagate extraQueryParameters, ensuring these parameters are available throughout the API client stack. [1] [2]

URL utilities and API request handling:

  • Introduced the addQueryParametersToUrl utility function in UrlUtils.ts, which safely adds/overwrites query parameters in URLs, and integrated this function into API request construction to append the extra parameters to outgoing requests. [1] [2] [3]

Testing and validation:

  • Added detailed unit tests for CustomAuthApiClient and addQueryParametersToUrl to verify correct handling of extra query parameters, including cases for single, multiple, undefined, empty, and overwriting scenarios. [1] [2] [3]
Copilot AI review requested due to automatic review settings August 6, 2025 16:20
@github-actions github-actions bot added the msal-browser Related to msal-browser package label Aug 6, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for passing extra query parameters (dc and slice) to custom authentication API requests in the MSAL browser library. This enhancement enables clients to specify datacenter and slice information in API calls for improved routing and flexibility.

  • Added extraQueryParameters to configuration types with typed keys for dc and slice
  • Updated API client constructors to accept and propagate extra query parameters throughout the client stack
  • Introduced URL utility function to safely add/overwrite query parameters in API requests

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
CustomAuthConfiguration.ts Added QueryKey type and extraQueryParameters field to CustomAuthOptions
CustomAuthStandardController.ts Updated to pass extraQueryParameters from config to CustomAuthApiClient
CustomAuthApiClient.ts Modified constructor to accept and pass extraQueryParameters to child API clients
BaseApiClient.ts Updated constructor to accept extraQueryParameters and use new URL utility to append them
UrlUtils.ts Added addQueryParametersToUrl utility function for safe query parameter handling
UrlUtils.spec.ts Added comprehensive tests for the new addQueryParametersToUrl function
CustomAuthApiClient.spec.ts Added tests for constructor with various extraQueryParameters scenarios
shenj
shenj previously approved these changes Aug 14, 2025
@yongdiw yongdiw requested a review from a team as a code owner August 15, 2025 08:31
hectormmg
hectormmg previously approved these changes Aug 22, 2025
hectormmg
hectormmg previously approved these changes Aug 25, 2025
@yongdiw yongdiw merged commit 8316ee5 into dev Aug 27, 2025
7 checks passed
@yongdiw yongdiw deleted the yongdi/add-dc branch August 27, 2025 18:50
yongdiw added a commit that referenced this pull request Aug 28, 2025
yongdiw added a commit that referenced this pull request Sep 12, 2025
Add extraQueryParams for api calls (#7974)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

msal-browser Related to msal-browser package

4 participants