@azure/msal-node 3.3.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/cache/NodeStorage.mjs +1 -1
  2. package/dist/cache/TokenCache.mjs +1 -1
  3. package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
  4. package/dist/cache/serializer/Deserializer.mjs +1 -1
  5. package/dist/cache/serializer/Serializer.mjs +1 -1
  6. package/dist/client/ClientApplication.d.ts +3 -3
  7. package/dist/client/ClientApplication.d.ts.map +1 -1
  8. package/dist/client/ClientApplication.mjs +16 -17
  9. package/dist/client/ClientApplication.mjs.map +1 -1
  10. package/dist/client/ClientAssertion.mjs +1 -1
  11. package/dist/client/ClientCredentialClient.d.ts.map +1 -1
  12. package/dist/client/ClientCredentialClient.mjs +16 -16
  13. package/dist/client/ClientCredentialClient.mjs.map +1 -1
  14. package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
  15. package/dist/client/ConfidentialClientApplication.mjs +5 -3
  16. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  17. package/dist/client/DeviceCodeClient.d.ts.map +1 -1
  18. package/dist/client/DeviceCodeClient.mjs +24 -24
  19. package/dist/client/DeviceCodeClient.mjs.map +1 -1
  20. package/dist/client/ManagedIdentityApplication.mjs +1 -1
  21. package/dist/client/ManagedIdentityClient.mjs +1 -1
  22. package/dist/client/ManagedIdentitySources/AppService.mjs +1 -1
  23. package/dist/client/ManagedIdentitySources/AzureArc.mjs +1 -1
  24. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +1 -1
  25. package/dist/client/ManagedIdentitySources/CloudShell.mjs +1 -1
  26. package/dist/client/ManagedIdentitySources/Imds.mjs +1 -1
  27. package/dist/client/ManagedIdentitySources/MachineLearning.mjs +1 -1
  28. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +1 -1
  29. package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
  30. package/dist/client/OnBehalfOfClient.mjs +19 -19
  31. package/dist/client/OnBehalfOfClient.mjs.map +1 -1
  32. package/dist/client/PublicClientApplication.d.ts.map +1 -1
  33. package/dist/client/PublicClientApplication.mjs +3 -2
  34. package/dist/client/PublicClientApplication.mjs.map +1 -1
  35. package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
  36. package/dist/client/UsernamePasswordClient.mjs +21 -21
  37. package/dist/client/UsernamePasswordClient.mjs.map +1 -1
  38. package/dist/config/Configuration.mjs +1 -1
  39. package/dist/config/ManagedIdentityId.mjs +1 -1
  40. package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  41. package/dist/config/ManagedIdentityRequestParameters.mjs +8 -8
  42. package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -1
  43. package/dist/crypto/CryptoProvider.mjs +1 -1
  44. package/dist/crypto/GuidGenerator.mjs +1 -1
  45. package/dist/crypto/HashUtils.mjs +1 -1
  46. package/dist/crypto/PkceGenerator.mjs +1 -1
  47. package/dist/error/ManagedIdentityError.mjs +1 -1
  48. package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
  49. package/dist/error/NodeAuthError.mjs +1 -1
  50. package/dist/index.d.ts +5 -1
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.mjs +1 -1
  53. package/dist/internals.mjs +1 -1
  54. package/dist/network/HttpClient.mjs +1 -1
  55. package/dist/network/HttpClientWithRetries.mjs +1 -1
  56. package/dist/network/ILoopbackClient.d.ts +2 -2
  57. package/dist/network/ILoopbackClient.d.ts.map +1 -1
  58. package/dist/network/LoopbackClient.d.ts +2 -2
  59. package/dist/network/LoopbackClient.d.ts.map +1 -1
  60. package/dist/network/LoopbackClient.mjs +3 -2
  61. package/dist/network/LoopbackClient.mjs.map +1 -1
  62. package/dist/packageMetadata.d.ts +1 -1
  63. package/dist/packageMetadata.mjs +2 -2
  64. package/dist/protocol/Authorize.d.ts +12 -0
  65. package/dist/protocol/Authorize.d.ts.map +1 -0
  66. package/dist/protocol/Authorize.mjs +43 -0
  67. package/dist/protocol/Authorize.mjs.map +1 -0
  68. package/dist/retry/LinearRetryPolicy.mjs +1 -1
  69. package/dist/utils/Constants.mjs +1 -1
  70. package/dist/utils/EncodingUtils.mjs +1 -1
  71. package/dist/utils/NetworkUtils.mjs +1 -1
  72. package/dist/utils/TimeUtils.mjs +1 -1
  73. package/lib/msal-node.cjs +863 -933
  74. package/lib/msal-node.cjs.map +1 -1
  75. package/lib/types/client/ClientApplication.d.ts +3 -3
  76. package/lib/types/client/ClientApplication.d.ts.map +1 -1
  77. package/lib/types/client/ClientCredentialClient.d.ts.map +1 -1
  78. package/lib/types/client/ConfidentialClientApplication.d.ts.map +1 -1
  79. package/lib/types/client/DeviceCodeClient.d.ts.map +1 -1
  80. package/lib/types/client/OnBehalfOfClient.d.ts.map +1 -1
  81. package/lib/types/client/PublicClientApplication.d.ts.map +1 -1
  82. package/lib/types/client/UsernamePasswordClient.d.ts.map +1 -1
  83. package/lib/types/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  84. package/lib/types/index.d.ts +5 -1
  85. package/lib/types/index.d.ts.map +1 -1
  86. package/lib/types/network/ILoopbackClient.d.ts +2 -2
  87. package/lib/types/network/ILoopbackClient.d.ts.map +1 -1
  88. package/lib/types/network/LoopbackClient.d.ts +2 -2
  89. package/lib/types/network/LoopbackClient.d.ts.map +1 -1
  90. package/lib/types/packageMetadata.d.ts +1 -1
  91. package/lib/types/protocol/Authorize.d.ts +12 -0
  92. package/lib/types/protocol/Authorize.d.ts.map +1 -0
  93. package/package.json +2 -2
  94. package/src/client/ClientApplication.ts +44 -44
  95. package/src/client/ClientCredentialClient.ts +32 -14
  96. package/src/client/ConfidentialClientApplication.ts +15 -7
  97. package/src/client/DeviceCodeClient.ts +46 -24
  98. package/src/client/OnBehalfOfClient.ts +38 -17
  99. package/src/client/PublicClientApplication.ts +9 -5
  100. package/src/client/UsernamePasswordClient.ts +41 -19
  101. package/src/config/ManagedIdentityRequestParameters.ts +17 -7
  102. package/src/index.ts +5 -2
  103. package/src/network/ILoopbackClient.ts +2 -2
  104. package/src/network/LoopbackClient.ts +43 -46
  105. package/src/packageMetadata.ts +1 -1
  106. package/src/protocol/Authorize.ts +69 -0
package/lib/msal-node.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-node v3.3.0 2025-03-11 */
1
+ /*! @azure/msal-node v3.4.1 2025-03-25 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -152,7 +152,7 @@ class Serializer {
152
152
  }
153
153
  }
154
154
 
155
- /*! @azure/msal-common v15.2.1 2025-03-11 */
155
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
156
156
  /*
157
157
  * Copyright (c) Microsoft Corporation. All rights reserved.
158
158
  * Licensed under the MIT License.
@@ -187,11 +187,8 @@ const Constants$1 = {
187
187
  PROFILE_SCOPE: "profile",
188
188
  OFFLINE_ACCESS_SCOPE: "offline_access",
189
189
  EMAIL_SCOPE: "email",
190
- // Default response type for authorization code flow
191
- CODE_RESPONSE_TYPE: "code",
192
190
  CODE_GRANT_TYPE: "authorization_code",
193
191
  RT_GRANT_TYPE: "refresh_token",
194
- FRAGMENT_RESPONSE_MODE: "fragment",
195
192
  S256_CODE_CHALLENGE_METHOD: "S256",
196
193
  URL_FORM_CONTENT_TYPE: "application/x-www-form-urlencoded;charset=utf-8",
197
194
  AUTHORIZATION_PENDING: "authorization_pending",
@@ -211,8 +208,6 @@ const Constants$1 = {
211
208
  "login.microsoft.com",
212
209
  "sts.windows.net",
213
210
  ],
214
- TOKEN_RESPONSE_TYPE: "token",
215
- ID_TOKEN_RESPONSE_TYPE: "id_token",
216
211
  SHR_NONCE_VALIDITY: 240,
217
212
  INVALID_INSTANCE: "invalid_instance",
218
213
  };
@@ -291,17 +286,19 @@ const CodeChallengeMethodValues = {
291
286
  S256: "S256",
292
287
  };
293
288
  /**
294
- * allowed values for server response type
289
+ * Allowed values for response_type
295
290
  */
296
- const ServerResponseType = {
297
- QUERY: "query",
298
- FRAGMENT: "fragment",
291
+ const OAuthResponseType = {
292
+ CODE: "code",
293
+ IDTOKEN_TOKEN: "id_token token",
294
+ IDTOKEN_TOKEN_REFRESHTOKEN: "id_token token refresh_token",
299
295
  };
300
296
  /**
301
297
  * allowed values for response_mode
302
298
  */
303
299
  const ResponseMode = {
304
- ...ServerResponseType,
300
+ QUERY: "query",
301
+ FRAGMENT: "fragment",
305
302
  FORM_POST: "form_post",
306
303
  };
307
304
  /**
@@ -445,7 +442,7 @@ const CacheOutcome = {
445
442
  // Token renewal offset default in seconds
446
443
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
447
444
 
448
- /*! @azure/msal-common v15.2.1 2025-03-11 */
445
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
449
446
  /*
450
447
  * Copyright (c) Microsoft Corporation. All rights reserved.
451
448
  * Licensed under the MIT License.
@@ -462,7 +459,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
462
459
  unexpectedError: unexpectedError
463
460
  });
464
461
 
465
- /*! @azure/msal-common v15.2.1 2025-03-11 */
462
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
466
463
 
467
464
  /*
468
465
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -511,7 +508,7 @@ function createAuthError(code, additionalMessage) {
511
508
  : AuthErrorMessages[code]);
512
509
  }
513
510
 
514
- /*! @azure/msal-common v15.2.1 2025-03-11 */
511
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
515
512
  /*
516
513
  * Copyright (c) Microsoft Corporation. All rights reserved.
517
514
  * Licensed under the MIT License.
@@ -609,7 +606,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
609
606
  userTimeoutReached: userTimeoutReached
610
607
  });
611
608
 
612
- /*! @azure/msal-common v15.2.1 2025-03-11 */
609
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
613
610
 
614
611
  /*
615
612
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -861,7 +858,7 @@ function createClientAuthError(errorCode, additionalMessage) {
861
858
  return new ClientAuthError(errorCode, additionalMessage);
862
859
  }
863
860
 
864
- /*! @azure/msal-common v15.2.1 2025-03-11 */
861
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
865
862
 
866
863
  /*
867
864
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -900,7 +897,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
900
897
  },
901
898
  };
902
899
 
903
- /*! @azure/msal-common v15.2.1 2025-03-11 */
900
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
904
901
 
905
902
  /*
906
903
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1091,12 +1088,12 @@ class Logger {
1091
1088
  }
1092
1089
  }
1093
1090
 
1094
- /*! @azure/msal-common v15.2.1 2025-03-11 */
1091
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
1095
1092
  /* eslint-disable header/header */
1096
1093
  const name$1 = "@azure/msal-common";
1097
- const version$1 = "15.2.1";
1094
+ const version$1 = "15.4.0";
1098
1095
 
1099
- /*! @azure/msal-common v15.2.1 2025-03-11 */
1096
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
1100
1097
  /*
1101
1098
  * Copyright (c) Microsoft Corporation. All rights reserved.
1102
1099
  * Licensed under the MIT License.
@@ -1116,7 +1113,7 @@ const AzureCloudInstance = {
1116
1113
  AzureUsGovernment: "https://login.microsoftonline.us",
1117
1114
  };
1118
1115
 
1119
- /*! @azure/msal-common v15.2.1 2025-03-11 */
1116
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
1120
1117
 
1121
1118
  /*
1122
1119
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1177,7 +1174,7 @@ function checkMaxAge(authTime, maxAge) {
1177
1174
  }
1178
1175
  }
1179
1176
 
1180
- /*! @azure/msal-common v15.2.1 2025-03-11 */
1177
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
1181
1178
  /*
1182
1179
  * Copyright (c) Microsoft Corporation. All rights reserved.
1183
1180
  * Licensed under the MIT License.
@@ -1232,7 +1229,7 @@ function delay(t, value) {
1232
1229
  return new Promise((resolve) => setTimeout(() => resolve(value), t));
1233
1230
  }
1234
1231
 
1235
- /*! @azure/msal-common v15.2.1 2025-03-11 */
1232
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
1236
1233
 
1237
1234
  /*
1238
1235
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1559,7 +1556,7 @@ function isAuthorityMetadataExpired(metadata) {
1559
1556
  return metadata.expiresAt <= nowSeconds();
1560
1557
  }
1561
1558
 
1562
- /*! @azure/msal-common v15.2.1 2025-03-11 */
1559
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
1563
1560
  /*
1564
1561
  * Copyright (c) Microsoft Corporation. All rights reserved.
1565
1562
  * Licensed under the MIT License.
@@ -1613,7 +1610,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1613
1610
  urlParseError: urlParseError
1614
1611
  });
1615
1612
 
1616
- /*! @azure/msal-common v15.2.1 2025-03-11 */
1613
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
1617
1614
 
1618
1615
  /*
1619
1616
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1751,7 +1748,7 @@ function createClientConfigurationError(errorCode) {
1751
1748
  return new ClientConfigurationError(errorCode);
1752
1749
  }
1753
1750
 
1754
- /*! @azure/msal-common v15.2.1 2025-03-11 */
1751
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
1755
1752
  /*
1756
1753
  * Copyright (c) Microsoft Corporation. All rights reserved.
1757
1754
  * Licensed under the MIT License.
@@ -1848,7 +1845,7 @@ class StringUtils {
1848
1845
  }
1849
1846
  }
1850
1847
 
1851
- /*! @azure/msal-common v15.2.1 2025-03-11 */
1848
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
1852
1849
 
1853
1850
  /*
1854
1851
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2039,7 +2036,7 @@ class ScopeSet {
2039
2036
  }
2040
2037
  }
2041
2038
 
2042
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2039
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2043
2040
 
2044
2041
  /*
2045
2042
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2079,7 +2076,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
2079
2076
  };
2080
2077
  }
2081
2078
 
2082
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2079
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2083
2080
  /*
2084
2081
  * Copyright (c) Microsoft Corporation. All rights reserved.
2085
2082
  * Licensed under the MIT License.
@@ -2158,7 +2155,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
2158
2155
  return updatedAccountInfo;
2159
2156
  }
2160
2157
 
2161
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2158
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2162
2159
  /*
2163
2160
  * Copyright (c) Microsoft Corporation. All rights reserved.
2164
2161
  * Licensed under the MIT License.
@@ -2173,7 +2170,7 @@ const AuthorityType = {
2173
2170
  Ciam: 3,
2174
2171
  };
2175
2172
 
2176
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2173
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2177
2174
  /*
2178
2175
  * Copyright (c) Microsoft Corporation. All rights reserved.
2179
2176
  * Licensed under the MIT License.
@@ -2195,7 +2192,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
2195
2192
  return null;
2196
2193
  }
2197
2194
 
2198
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2195
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2199
2196
  /*
2200
2197
  * Copyright (c) Microsoft Corporation. All rights reserved.
2201
2198
  * Licensed under the MIT License.
@@ -2204,11 +2201,22 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
2204
2201
  * Protocol modes supported by MSAL.
2205
2202
  */
2206
2203
  const ProtocolMode = {
2204
+ /**
2205
+ * Auth Code + PKCE with Entra ID (formerly AAD) specific optimizations and features
2206
+ */
2207
2207
  AAD: "AAD",
2208
+ /**
2209
+ * Auth Code + PKCE without Entra ID specific optimizations and features. For use only with non-Microsoft owned authorities.
2210
+ * Support is limited for this mode.
2211
+ */
2208
2212
  OIDC: "OIDC",
2213
+ /**
2214
+ * Encrypted Authorize Response (EAR) with Entra ID specific optimizations and features
2215
+ */
2216
+ EAR: "EAR",
2209
2217
  };
2210
2218
 
2211
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2219
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2212
2220
 
2213
2221
  /*
2214
2222
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2304,11 +2312,11 @@ class AccountEntity {
2304
2312
  if (authority.authorityType === AuthorityType.Adfs) {
2305
2313
  account.authorityType = CacheAccountType.ADFS_ACCOUNT_TYPE;
2306
2314
  }
2307
- else if (authority.protocolMode === ProtocolMode.AAD) {
2308
- account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
2315
+ else if (authority.protocolMode === ProtocolMode.OIDC) {
2316
+ account.authorityType = CacheAccountType.GENERIC_ACCOUNT_TYPE;
2309
2317
  }
2310
2318
  else {
2311
- account.authorityType = CacheAccountType.GENERIC_ACCOUNT_TYPE;
2319
+ account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
2312
2320
  }
2313
2321
  let clientInfo;
2314
2322
  if (accountDetails.clientInfo && base64Decode) {
@@ -2451,7 +2459,7 @@ class AccountEntity {
2451
2459
  }
2452
2460
  }
2453
2461
 
2454
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2462
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2455
2463
 
2456
2464
  /*
2457
2465
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2486,6 +2494,7 @@ function getDeserializedResponse(responseString) {
2486
2494
  const deserializedHash = Object.fromEntries(new URLSearchParams(normalizedResponse));
2487
2495
  // Check for known response properties
2488
2496
  if (deserializedHash.code ||
2497
+ deserializedHash.ear_jwe ||
2489
2498
  deserializedHash.error ||
2490
2499
  deserializedHash.error_description ||
2491
2500
  deserializedHash.state) {
@@ -2496,9 +2505,19 @@ function getDeserializedResponse(responseString) {
2496
2505
  throw createClientAuthError(hashNotDeserialized);
2497
2506
  }
2498
2507
  return null;
2508
+ }
2509
+ /**
2510
+ * Utility to create a URL from the params map
2511
+ */
2512
+ function mapToQueryString(parameters) {
2513
+ const queryParameterArray = new Array();
2514
+ parameters.forEach((value, key) => {
2515
+ queryParameterArray.push(`${key}=${encodeURIComponent(value)}`);
2516
+ });
2517
+ return queryParameterArray.join("&");
2499
2518
  }
2500
2519
 
2501
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2520
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2502
2521
 
2503
2522
  /*
2504
2523
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2662,7 +2681,7 @@ class UrlString {
2662
2681
  }
2663
2682
  }
2664
2683
 
2665
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2684
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2666
2685
 
2667
2686
  /*
2668
2687
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2802,7 +2821,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2802
2821
  return null;
2803
2822
  }
2804
2823
 
2805
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2824
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2806
2825
  /*
2807
2826
  * Copyright (c) Microsoft Corporation. All rights reserved.
2808
2827
  * Licensed under the MIT License.
@@ -2810,7 +2829,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2810
2829
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2811
2830
  const cacheUnknownErrorCode = "cache_error_unknown";
2812
2831
 
2813
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2832
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2814
2833
 
2815
2834
  /*
2816
2835
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2837,7 +2856,7 @@ class CacheError extends Error {
2837
2856
  }
2838
2857
  }
2839
2858
 
2840
- /*! @azure/msal-common v15.2.1 2025-03-11 */
2859
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
2841
2860
 
2842
2861
  /*
2843
2862
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4021,7 +4040,7 @@ class DefaultStorageClass extends CacheManager {
4021
4040
  }
4022
4041
  }
4023
4042
 
4024
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4043
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
4025
4044
 
4026
4045
  /*
4027
4046
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4120,7 +4139,7 @@ function isOidcProtocolMode(config) {
4120
4139
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4121
4140
  }
4122
4141
 
4123
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4142
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
4124
4143
  /*
4125
4144
  * Copyright (c) Microsoft Corporation. All rights reserved.
4126
4145
  * Licensed under the MIT License.
@@ -4130,7 +4149,7 @@ const CcsCredentialType = {
4130
4149
  UPN: "UPN",
4131
4150
  };
4132
4151
 
4133
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4152
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
4134
4153
  /*
4135
4154
  * Copyright (c) Microsoft Corporation. All rights reserved.
4136
4155
  * Licensed under the MIT License.
@@ -4172,83 +4191,16 @@ const OBO_ASSERTION = "assertion";
4172
4191
  const REQUESTED_TOKEN_USE = "requested_token_use";
4173
4192
  const ON_BEHALF_OF = "on_behalf_of";
4174
4193
  const RETURN_SPA_CODE = "return_spa_code";
4175
- const NATIVE_BROKER = "nativebroker";
4176
4194
  const LOGOUT_HINT = "logout_hint";
4177
4195
  const SID = "sid";
4178
4196
  const LOGIN_HINT = "login_hint";
4179
4197
  const DOMAIN_HINT = "domain_hint";
4180
4198
  const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
4181
4199
  const BROKER_CLIENT_ID = "brk_client_id";
4182
- const BROKER_REDIRECT_URI = "brk_redirect_uri";
4200
+ const BROKER_REDIRECT_URI = "brk_redirect_uri";
4201
+ const INSTANCE_AWARE = "instance_aware";
4183
4202
 
4184
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4185
-
4186
- /*
4187
- * Copyright (c) Microsoft Corporation. All rights reserved.
4188
- * Licensed under the MIT License.
4189
- */
4190
- /**
4191
- * Validates server consumable params from the "request" objects
4192
- */
4193
- class RequestValidator {
4194
- /**
4195
- * Utility to check if the `redirectUri` in the request is a non-null value
4196
- * @param redirectUri
4197
- */
4198
- static validateRedirectUri(redirectUri) {
4199
- if (!redirectUri) {
4200
- throw createClientConfigurationError(redirectUriEmpty);
4201
- }
4202
- }
4203
- /**
4204
- * Utility to validate prompt sent by the user in the request
4205
- * @param prompt
4206
- */
4207
- static validatePrompt(prompt) {
4208
- const promptValues = [];
4209
- for (const value in PromptValue) {
4210
- promptValues.push(PromptValue[value]);
4211
- }
4212
- if (promptValues.indexOf(prompt) < 0) {
4213
- throw createClientConfigurationError(invalidPromptValue);
4214
- }
4215
- }
4216
- static validateClaims(claims) {
4217
- try {
4218
- JSON.parse(claims);
4219
- }
4220
- catch (e) {
4221
- throw createClientConfigurationError(invalidClaims);
4222
- }
4223
- }
4224
- /**
4225
- * Utility to validate code_challenge and code_challenge_method
4226
- * @param codeChallenge
4227
- * @param codeChallengeMethod
4228
- */
4229
- static validateCodeChallengeParams(codeChallenge, codeChallengeMethod) {
4230
- if (!codeChallenge || !codeChallengeMethod) {
4231
- throw createClientConfigurationError(pkceParamsMissing);
4232
- }
4233
- else {
4234
- this.validateCodeChallengeMethod(codeChallengeMethod);
4235
- }
4236
- }
4237
- /**
4238
- * Utility to validate code_challenge_method
4239
- * @param codeChallengeMethod
4240
- */
4241
- static validateCodeChallengeMethod(codeChallengeMethod) {
4242
- if ([
4243
- CodeChallengeMethodValues.PLAIN,
4244
- CodeChallengeMethodValues.S256,
4245
- ].indexOf(codeChallengeMethod) < 0) {
4246
- throw createClientConfigurationError(invalidCodeChallengeMethod);
4247
- }
4248
- }
4249
- }
4250
-
4251
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4203
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
4252
4204
 
4253
4205
  /*
4254
4206
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4266,397 +4218,375 @@ function instrumentBrokerParams(parameters, correlationId, performanceClient) {
4266
4218
  }, correlationId);
4267
4219
  }
4268
4220
  }
4269
- /** @internal */
4270
- class RequestParameterBuilder {
4271
- constructor(correlationId, performanceClient) {
4272
- this.parameters = new Map();
4273
- this.performanceClient = performanceClient;
4274
- this.correlationId = correlationId;
4275
- }
4276
- /**
4277
- * add response_type = code
4278
- */
4279
- addResponseTypeCode() {
4280
- this.parameters.set(RESPONSE_TYPE, encodeURIComponent(Constants$1.CODE_RESPONSE_TYPE));
4281
- }
4282
- /**
4283
- * add response_type = token id_token
4284
- */
4285
- addResponseTypeForTokenAndIdToken() {
4286
- this.parameters.set(RESPONSE_TYPE, encodeURIComponent(`${Constants$1.TOKEN_RESPONSE_TYPE} ${Constants$1.ID_TOKEN_RESPONSE_TYPE}`));
4287
- }
4288
- /**
4289
- * add response_mode. defaults to query.
4290
- * @param responseMode
4291
- */
4292
- addResponseMode(responseMode) {
4293
- this.parameters.set(RESPONSE_MODE, encodeURIComponent(responseMode ? responseMode : ResponseMode.QUERY));
4294
- }
4295
- /**
4296
- * Add flag to indicate STS should attempt to use WAM if available
4297
- */
4298
- addNativeBroker() {
4299
- this.parameters.set(NATIVE_BROKER, encodeURIComponent("1"));
4300
- }
4301
- /**
4302
- * add scopes. set addOidcScopes to false to prevent default scopes in non-user scenarios
4303
- * @param scopeSet
4304
- * @param addOidcScopes
4305
- */
4306
- addScopes(scopes, addOidcScopes = true, defaultScopes = OIDC_DEFAULT_SCOPES) {
4307
- // Always add openid to the scopes when adding OIDC scopes
4308
- if (addOidcScopes &&
4309
- !defaultScopes.includes("openid") &&
4310
- !scopes.includes("openid")) {
4311
- defaultScopes.push("openid");
4312
- }
4313
- const requestScopes = addOidcScopes
4314
- ? [...(scopes || []), ...defaultScopes]
4315
- : scopes || [];
4316
- const scopeSet = new ScopeSet(requestScopes);
4317
- this.parameters.set(SCOPE, encodeURIComponent(scopeSet.printScopes()));
4318
- }
4319
- /**
4320
- * add clientId
4321
- * @param clientId
4322
- */
4323
- addClientId(clientId) {
4324
- this.parameters.set(CLIENT_ID, encodeURIComponent(clientId));
4325
- }
4326
- /**
4327
- * add redirect_uri
4328
- * @param redirectUri
4329
- */
4330
- addRedirectUri(redirectUri) {
4331
- RequestValidator.validateRedirectUri(redirectUri);
4332
- this.parameters.set(REDIRECT_URI, encodeURIComponent(redirectUri));
4333
- }
4334
- /**
4335
- * add post logout redirectUri
4336
- * @param redirectUri
4337
- */
4338
- addPostLogoutRedirectUri(redirectUri) {
4339
- RequestValidator.validateRedirectUri(redirectUri);
4340
- this.parameters.set(POST_LOGOUT_URI, encodeURIComponent(redirectUri));
4341
- }
4342
- /**
4343
- * add id_token_hint to logout request
4344
- * @param idTokenHint
4345
- */
4346
- addIdTokenHint(idTokenHint) {
4347
- this.parameters.set(ID_TOKEN_HINT, encodeURIComponent(idTokenHint));
4348
- }
4349
- /**
4350
- * add domain_hint
4351
- * @param domainHint
4352
- */
4353
- addDomainHint(domainHint) {
4354
- this.parameters.set(DOMAIN_HINT, encodeURIComponent(domainHint));
4355
- }
4356
- /**
4357
- * add login_hint
4358
- * @param loginHint
4359
- */
4360
- addLoginHint(loginHint) {
4361
- this.parameters.set(LOGIN_HINT, encodeURIComponent(loginHint));
4362
- }
4363
- /**
4364
- * Adds the CCS (Cache Credential Service) query parameter for login_hint
4365
- * @param loginHint
4366
- */
4367
- addCcsUpn(loginHint) {
4368
- this.parameters.set(HeaderNames.CCS_HEADER, encodeURIComponent(`UPN:${loginHint}`));
4369
- }
4370
- /**
4371
- * Adds the CCS (Cache Credential Service) query parameter for account object
4372
- * @param loginHint
4373
- */
4374
- addCcsOid(clientInfo) {
4375
- this.parameters.set(HeaderNames.CCS_HEADER, encodeURIComponent(`Oid:${clientInfo.uid}@${clientInfo.utid}`));
4376
- }
4377
- /**
4378
- * add sid
4379
- * @param sid
4380
- */
4381
- addSid(sid) {
4382
- this.parameters.set(SID, encodeURIComponent(sid));
4383
- }
4384
- /**
4385
- * add claims
4386
- * @param claims
4387
- */
4388
- addClaims(claims, clientCapabilities) {
4389
- const mergedClaims = this.addClientCapabilitiesToClaims(claims, clientCapabilities);
4390
- RequestValidator.validateClaims(mergedClaims);
4391
- this.parameters.set(CLAIMS, encodeURIComponent(mergedClaims));
4392
- }
4393
- /**
4394
- * add correlationId
4395
- * @param correlationId
4396
- */
4397
- addCorrelationId(correlationId) {
4398
- this.parameters.set(CLIENT_REQUEST_ID, encodeURIComponent(correlationId));
4399
- }
4400
- /**
4401
- * add library info query params
4402
- * @param libraryInfo
4403
- */
4404
- addLibraryInfo(libraryInfo) {
4405
- // Telemetry Info
4406
- this.parameters.set(X_CLIENT_SKU, libraryInfo.sku);
4407
- this.parameters.set(X_CLIENT_VER, libraryInfo.version);
4408
- if (libraryInfo.os) {
4409
- this.parameters.set(X_CLIENT_OS, libraryInfo.os);
4410
- }
4411
- if (libraryInfo.cpu) {
4412
- this.parameters.set(X_CLIENT_CPU, libraryInfo.cpu);
4413
- }
4414
- }
4415
- /**
4416
- * Add client telemetry parameters
4417
- * @param appTelemetry
4418
- */
4419
- addApplicationTelemetry(appTelemetry) {
4420
- if (appTelemetry?.appName) {
4421
- this.parameters.set(X_APP_NAME, appTelemetry.appName);
4422
- }
4423
- if (appTelemetry?.appVersion) {
4424
- this.parameters.set(X_APP_VER, appTelemetry.appVersion);
4425
- }
4426
- }
4427
- /**
4428
- * add prompt
4429
- * @param prompt
4430
- */
4431
- addPrompt(prompt) {
4432
- RequestValidator.validatePrompt(prompt);
4433
- this.parameters.set(`${PROMPT}`, encodeURIComponent(prompt));
4434
- }
4435
- /**
4436
- * add state
4437
- * @param state
4438
- */
4439
- addState(state) {
4440
- if (state) {
4441
- this.parameters.set(STATE, encodeURIComponent(state));
4442
- }
4443
- }
4444
- /**
4445
- * add nonce
4446
- * @param nonce
4447
- */
4448
- addNonce(nonce) {
4449
- this.parameters.set(NONCE, encodeURIComponent(nonce));
4450
- }
4451
- /**
4452
- * add code_challenge and code_challenge_method
4453
- * - throw if either of them are not passed
4454
- * @param codeChallenge
4455
- * @param codeChallengeMethod
4456
- */
4457
- addCodeChallengeParams(codeChallenge, codeChallengeMethod) {
4458
- RequestValidator.validateCodeChallengeParams(codeChallenge, codeChallengeMethod);
4459
- if (codeChallenge && codeChallengeMethod) {
4460
- this.parameters.set(CODE_CHALLENGE, encodeURIComponent(codeChallenge));
4461
- this.parameters.set(CODE_CHALLENGE_METHOD, encodeURIComponent(codeChallengeMethod));
4462
- }
4463
- else {
4464
- throw createClientConfigurationError(pkceParamsMissing);
4465
- }
4466
- }
4467
- /**
4468
- * add the `authorization_code` passed by the user to exchange for a token
4469
- * @param code
4470
- */
4471
- addAuthorizationCode(code) {
4472
- this.parameters.set(CODE, encodeURIComponent(code));
4221
+ /**
4222
+ * Add the given response_type
4223
+ * @param parameters
4224
+ * @param responseType
4225
+ */
4226
+ function addResponseType(parameters, responseType) {
4227
+ parameters.set(RESPONSE_TYPE, responseType);
4228
+ }
4229
+ /**
4230
+ * add response_mode. defaults to query.
4231
+ * @param responseMode
4232
+ */
4233
+ function addResponseMode(parameters, responseMode) {
4234
+ parameters.set(RESPONSE_MODE, responseMode ? responseMode : ResponseMode.QUERY);
4235
+ }
4236
+ /**
4237
+ * add scopes. set addOidcScopes to false to prevent default scopes in non-user scenarios
4238
+ * @param scopeSet
4239
+ * @param addOidcScopes
4240
+ */
4241
+ function addScopes(parameters, scopes, addOidcScopes = true, defaultScopes = OIDC_DEFAULT_SCOPES) {
4242
+ // Always add openid to the scopes when adding OIDC scopes
4243
+ if (addOidcScopes &&
4244
+ !defaultScopes.includes("openid") &&
4245
+ !scopes.includes("openid")) {
4246
+ defaultScopes.push("openid");
4247
+ }
4248
+ const requestScopes = addOidcScopes
4249
+ ? [...(scopes || []), ...defaultScopes]
4250
+ : scopes || [];
4251
+ const scopeSet = new ScopeSet(requestScopes);
4252
+ parameters.set(SCOPE, scopeSet.printScopes());
4253
+ }
4254
+ /**
4255
+ * add clientId
4256
+ * @param clientId
4257
+ */
4258
+ function addClientId(parameters, clientId) {
4259
+ parameters.set(CLIENT_ID, clientId);
4260
+ }
4261
+ /**
4262
+ * add redirect_uri
4263
+ * @param redirectUri
4264
+ */
4265
+ function addRedirectUri(parameters, redirectUri) {
4266
+ parameters.set(REDIRECT_URI, redirectUri);
4267
+ }
4268
+ /**
4269
+ * add post logout redirectUri
4270
+ * @param redirectUri
4271
+ */
4272
+ function addPostLogoutRedirectUri(parameters, redirectUri) {
4273
+ parameters.set(POST_LOGOUT_URI, redirectUri);
4274
+ }
4275
+ /**
4276
+ * add id_token_hint to logout request
4277
+ * @param idTokenHint
4278
+ */
4279
+ function addIdTokenHint(parameters, idTokenHint) {
4280
+ parameters.set(ID_TOKEN_HINT, idTokenHint);
4281
+ }
4282
+ /**
4283
+ * add domain_hint
4284
+ * @param domainHint
4285
+ */
4286
+ function addDomainHint(parameters, domainHint) {
4287
+ parameters.set(DOMAIN_HINT, domainHint);
4288
+ }
4289
+ /**
4290
+ * add login_hint
4291
+ * @param loginHint
4292
+ */
4293
+ function addLoginHint(parameters, loginHint) {
4294
+ parameters.set(LOGIN_HINT, loginHint);
4295
+ }
4296
+ /**
4297
+ * Adds the CCS (Cache Credential Service) query parameter for login_hint
4298
+ * @param loginHint
4299
+ */
4300
+ function addCcsUpn(parameters, loginHint) {
4301
+ parameters.set(HeaderNames.CCS_HEADER, `UPN:${loginHint}`);
4302
+ }
4303
+ /**
4304
+ * Adds the CCS (Cache Credential Service) query parameter for account object
4305
+ * @param loginHint
4306
+ */
4307
+ function addCcsOid(parameters, clientInfo) {
4308
+ parameters.set(HeaderNames.CCS_HEADER, `Oid:${clientInfo.uid}@${clientInfo.utid}`);
4309
+ }
4310
+ /**
4311
+ * add sid
4312
+ * @param sid
4313
+ */
4314
+ function addSid(parameters, sid) {
4315
+ parameters.set(SID, sid);
4316
+ }
4317
+ /**
4318
+ * add claims
4319
+ * @param claims
4320
+ */
4321
+ function addClaims(parameters, claims, clientCapabilities) {
4322
+ const mergedClaims = addClientCapabilitiesToClaims(claims, clientCapabilities);
4323
+ try {
4324
+ JSON.parse(mergedClaims);
4473
4325
  }
4474
- /**
4475
- * add the `authorization_code` passed by the user to exchange for a token
4476
- * @param code
4477
- */
4478
- addDeviceCode(code) {
4479
- this.parameters.set(DEVICE_CODE, encodeURIComponent(code));
4326
+ catch (e) {
4327
+ throw createClientConfigurationError(invalidClaims);
4480
4328
  }
4481
- /**
4482
- * add the `refreshToken` passed by the user
4483
- * @param refreshToken
4484
- */
4485
- addRefreshToken(refreshToken) {
4486
- this.parameters.set(REFRESH_TOKEN, encodeURIComponent(refreshToken));
4329
+ parameters.set(CLAIMS, mergedClaims);
4330
+ }
4331
+ /**
4332
+ * add correlationId
4333
+ * @param correlationId
4334
+ */
4335
+ function addCorrelationId(parameters, correlationId) {
4336
+ parameters.set(CLIENT_REQUEST_ID, correlationId);
4337
+ }
4338
+ /**
4339
+ * add library info query params
4340
+ * @param libraryInfo
4341
+ */
4342
+ function addLibraryInfo(parameters, libraryInfo) {
4343
+ // Telemetry Info
4344
+ parameters.set(X_CLIENT_SKU, libraryInfo.sku);
4345
+ parameters.set(X_CLIENT_VER, libraryInfo.version);
4346
+ if (libraryInfo.os) {
4347
+ parameters.set(X_CLIENT_OS, libraryInfo.os);
4487
4348
  }
4488
- /**
4489
- * add the `code_verifier` passed by the user to exchange for a token
4490
- * @param codeVerifier
4491
- */
4492
- addCodeVerifier(codeVerifier) {
4493
- this.parameters.set(CODE_VERIFIER, encodeURIComponent(codeVerifier));
4349
+ if (libraryInfo.cpu) {
4350
+ parameters.set(X_CLIENT_CPU, libraryInfo.cpu);
4494
4351
  }
4495
- /**
4496
- * add client_secret
4497
- * @param clientSecret
4498
- */
4499
- addClientSecret(clientSecret) {
4500
- this.parameters.set(CLIENT_SECRET, encodeURIComponent(clientSecret));
4352
+ }
4353
+ /**
4354
+ * Add client telemetry parameters
4355
+ * @param appTelemetry
4356
+ */
4357
+ function addApplicationTelemetry(parameters, appTelemetry) {
4358
+ if (appTelemetry?.appName) {
4359
+ parameters.set(X_APP_NAME, appTelemetry.appName);
4501
4360
  }
4502
- /**
4503
- * add clientAssertion for confidential client flows
4504
- * @param clientAssertion
4505
- */
4506
- addClientAssertion(clientAssertion) {
4507
- if (clientAssertion) {
4508
- this.parameters.set(CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
4509
- }
4361
+ if (appTelemetry?.appVersion) {
4362
+ parameters.set(X_APP_VER, appTelemetry.appVersion);
4510
4363
  }
4511
- /**
4512
- * add clientAssertionType for confidential client flows
4513
- * @param clientAssertionType
4514
- */
4515
- addClientAssertionType(clientAssertionType) {
4516
- if (clientAssertionType) {
4517
- this.parameters.set(CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
4518
- }
4364
+ }
4365
+ /**
4366
+ * add prompt
4367
+ * @param prompt
4368
+ */
4369
+ function addPrompt(parameters, prompt) {
4370
+ parameters.set(PROMPT, prompt);
4371
+ }
4372
+ /**
4373
+ * add state
4374
+ * @param state
4375
+ */
4376
+ function addState(parameters, state) {
4377
+ if (state) {
4378
+ parameters.set(STATE, state);
4519
4379
  }
4520
- /**
4521
- * add OBO assertion for confidential client flows
4522
- * @param clientAssertion
4523
- */
4524
- addOboAssertion(oboAssertion) {
4525
- this.parameters.set(OBO_ASSERTION, encodeURIComponent(oboAssertion));
4380
+ }
4381
+ /**
4382
+ * add nonce
4383
+ * @param nonce
4384
+ */
4385
+ function addNonce(parameters, nonce) {
4386
+ parameters.set(NONCE, nonce);
4387
+ }
4388
+ /**
4389
+ * add code_challenge and code_challenge_method
4390
+ * - throw if either of them are not passed
4391
+ * @param codeChallenge
4392
+ * @param codeChallengeMethod
4393
+ */
4394
+ function addCodeChallengeParams(parameters, codeChallenge, codeChallengeMethod) {
4395
+ if (codeChallenge && codeChallengeMethod) {
4396
+ parameters.set(CODE_CHALLENGE, codeChallenge);
4397
+ parameters.set(CODE_CHALLENGE_METHOD, codeChallengeMethod);
4526
4398
  }
4527
- /**
4528
- * add grant type
4529
- * @param grantType
4530
- */
4531
- addRequestTokenUse(tokenUse) {
4532
- this.parameters.set(REQUESTED_TOKEN_USE, encodeURIComponent(tokenUse));
4399
+ else {
4400
+ throw createClientConfigurationError(pkceParamsMissing);
4533
4401
  }
4534
- /**
4535
- * add grant type
4536
- * @param grantType
4537
- */
4538
- addGrantType(grantType) {
4539
- this.parameters.set(GRANT_TYPE, encodeURIComponent(grantType));
4402
+ }
4403
+ /**
4404
+ * add the `authorization_code` passed by the user to exchange for a token
4405
+ * @param code
4406
+ */
4407
+ function addAuthorizationCode(parameters, code) {
4408
+ parameters.set(CODE, code);
4409
+ }
4410
+ /**
4411
+ * add the `authorization_code` passed by the user to exchange for a token
4412
+ * @param code
4413
+ */
4414
+ function addDeviceCode(parameters, code) {
4415
+ parameters.set(DEVICE_CODE, code);
4416
+ }
4417
+ /**
4418
+ * add the `refreshToken` passed by the user
4419
+ * @param refreshToken
4420
+ */
4421
+ function addRefreshToken(parameters, refreshToken) {
4422
+ parameters.set(REFRESH_TOKEN, refreshToken);
4423
+ }
4424
+ /**
4425
+ * add the `code_verifier` passed by the user to exchange for a token
4426
+ * @param codeVerifier
4427
+ */
4428
+ function addCodeVerifier(parameters, codeVerifier) {
4429
+ parameters.set(CODE_VERIFIER, codeVerifier);
4430
+ }
4431
+ /**
4432
+ * add client_secret
4433
+ * @param clientSecret
4434
+ */
4435
+ function addClientSecret(parameters, clientSecret) {
4436
+ parameters.set(CLIENT_SECRET, clientSecret);
4437
+ }
4438
+ /**
4439
+ * add clientAssertion for confidential client flows
4440
+ * @param clientAssertion
4441
+ */
4442
+ function addClientAssertion(parameters, clientAssertion) {
4443
+ if (clientAssertion) {
4444
+ parameters.set(CLIENT_ASSERTION, clientAssertion);
4540
4445
  }
4541
- /**
4542
- * add client info
4543
- *
4544
- */
4545
- addClientInfo() {
4546
- this.parameters.set(CLIENT_INFO, "1");
4446
+ }
4447
+ /**
4448
+ * add clientAssertionType for confidential client flows
4449
+ * @param clientAssertionType
4450
+ */
4451
+ function addClientAssertionType(parameters, clientAssertionType) {
4452
+ if (clientAssertionType) {
4453
+ parameters.set(CLIENT_ASSERTION_TYPE, clientAssertionType);
4547
4454
  }
4548
- /**
4549
- * add extraQueryParams
4550
- * @param eQParams
4551
- */
4552
- addExtraQueryParameters(eQParams) {
4553
- Object.entries(eQParams).forEach(([key, value]) => {
4554
- if (!this.parameters.has(key) && value) {
4555
- this.parameters.set(key, value);
4556
- }
4557
- });
4455
+ }
4456
+ /**
4457
+ * add OBO assertion for confidential client flows
4458
+ * @param clientAssertion
4459
+ */
4460
+ function addOboAssertion(parameters, oboAssertion) {
4461
+ parameters.set(OBO_ASSERTION, oboAssertion);
4462
+ }
4463
+ /**
4464
+ * add grant type
4465
+ * @param grantType
4466
+ */
4467
+ function addRequestTokenUse(parameters, tokenUse) {
4468
+ parameters.set(REQUESTED_TOKEN_USE, tokenUse);
4469
+ }
4470
+ /**
4471
+ * add grant type
4472
+ * @param grantType
4473
+ */
4474
+ function addGrantType(parameters, grantType) {
4475
+ parameters.set(GRANT_TYPE, grantType);
4476
+ }
4477
+ /**
4478
+ * add client info
4479
+ *
4480
+ */
4481
+ function addClientInfo(parameters) {
4482
+ parameters.set(CLIENT_INFO, "1");
4483
+ }
4484
+ function addInstanceAware(parameters) {
4485
+ if (!parameters.has(INSTANCE_AWARE)) {
4486
+ parameters.set(INSTANCE_AWARE, "true");
4558
4487
  }
4559
- addClientCapabilitiesToClaims(claims, clientCapabilities) {
4560
- let mergedClaims;
4561
- // Parse provided claims into JSON object or initialize empty object
4562
- if (!claims) {
4563
- mergedClaims = {};
4564
- }
4565
- else {
4566
- try {
4567
- mergedClaims = JSON.parse(claims);
4568
- }
4569
- catch (e) {
4570
- throw createClientConfigurationError(invalidClaims);
4571
- }
4572
- }
4573
- if (clientCapabilities && clientCapabilities.length > 0) {
4574
- if (!mergedClaims.hasOwnProperty(ClaimsRequestKeys.ACCESS_TOKEN)) {
4575
- // Add access_token key to claims object
4576
- mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN] = {};
4577
- }
4578
- // Add xms_cc claim with provided clientCapabilities to access_token key
4579
- mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN][ClaimsRequestKeys.XMS_CC] = {
4580
- values: clientCapabilities,
4581
- };
4488
+ }
4489
+ /**
4490
+ * add extraQueryParams
4491
+ * @param eQParams
4492
+ */
4493
+ function addExtraQueryParameters(parameters, eQParams) {
4494
+ Object.entries(eQParams).forEach(([key, value]) => {
4495
+ if (!parameters.has(key) && value) {
4496
+ parameters.set(key, value);
4582
4497
  }
4583
- return JSON.stringify(mergedClaims);
4584
- }
4585
- /**
4586
- * adds `username` for Password Grant flow
4587
- * @param username
4588
- */
4589
- addUsername(username) {
4590
- this.parameters.set(PasswordGrantConstants.username, encodeURIComponent(username));
4591
- }
4592
- /**
4593
- * adds `password` for Password Grant flow
4594
- * @param password
4595
- */
4596
- addPassword(password) {
4597
- this.parameters.set(PasswordGrantConstants.password, encodeURIComponent(password));
4498
+ });
4499
+ }
4500
+ function addClientCapabilitiesToClaims(claims, clientCapabilities) {
4501
+ let mergedClaims;
4502
+ // Parse provided claims into JSON object or initialize empty object
4503
+ if (!claims) {
4504
+ mergedClaims = {};
4598
4505
  }
4599
- /**
4600
- * add pop_jwk to query params
4601
- * @param cnfString
4602
- */
4603
- addPopToken(cnfString) {
4604
- if (cnfString) {
4605
- this.parameters.set(TOKEN_TYPE, AuthenticationScheme.POP);
4606
- this.parameters.set(REQ_CNF, encodeURIComponent(cnfString));
4506
+ else {
4507
+ try {
4508
+ mergedClaims = JSON.parse(claims);
4607
4509
  }
4608
- }
4609
- /**
4610
- * add SSH JWK and key ID to query params
4611
- */
4612
- addSshJwk(sshJwkString) {
4613
- if (sshJwkString) {
4614
- this.parameters.set(TOKEN_TYPE, AuthenticationScheme.SSH);
4615
- this.parameters.set(REQ_CNF, encodeURIComponent(sshJwkString));
4510
+ catch (e) {
4511
+ throw createClientConfigurationError(invalidClaims);
4616
4512
  }
4617
4513
  }
4618
- /**
4619
- * add server telemetry fields
4620
- * @param serverTelemetryManager
4621
- */
4622
- addServerTelemetry(serverTelemetryManager) {
4623
- this.parameters.set(X_CLIENT_CURR_TELEM, serverTelemetryManager.generateCurrentRequestHeaderValue());
4624
- this.parameters.set(X_CLIENT_LAST_TELEM, serverTelemetryManager.generateLastRequestHeaderValue());
4514
+ if (clientCapabilities && clientCapabilities.length > 0) {
4515
+ if (!mergedClaims.hasOwnProperty(ClaimsRequestKeys.ACCESS_TOKEN)) {
4516
+ // Add access_token key to claims object
4517
+ mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN] = {};
4518
+ }
4519
+ // Add xms_cc claim with provided clientCapabilities to access_token key
4520
+ mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN][ClaimsRequestKeys.XMS_CC] =
4521
+ {
4522
+ values: clientCapabilities,
4523
+ };
4625
4524
  }
4626
- /**
4627
- * Adds parameter that indicates to the server that throttling is supported
4628
- */
4629
- addThrottling() {
4630
- this.parameters.set(X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);
4525
+ return JSON.stringify(mergedClaims);
4526
+ }
4527
+ /**
4528
+ * adds `username` for Password Grant flow
4529
+ * @param username
4530
+ */
4531
+ function addUsername(parameters, username) {
4532
+ parameters.set(PasswordGrantConstants.username, username);
4533
+ }
4534
+ /**
4535
+ * adds `password` for Password Grant flow
4536
+ * @param password
4537
+ */
4538
+ function addPassword(parameters, password) {
4539
+ parameters.set(PasswordGrantConstants.password, password);
4540
+ }
4541
+ /**
4542
+ * add pop_jwk to query params
4543
+ * @param cnfString
4544
+ */
4545
+ function addPopToken(parameters, cnfString) {
4546
+ if (cnfString) {
4547
+ parameters.set(TOKEN_TYPE, AuthenticationScheme.POP);
4548
+ parameters.set(REQ_CNF, cnfString);
4631
4549
  }
4632
- /**
4633
- * Adds logout_hint parameter for "silent" logout which prevent server account picker
4634
- */
4635
- addLogoutHint(logoutHint) {
4636
- this.parameters.set(LOGOUT_HINT, encodeURIComponent(logoutHint));
4550
+ }
4551
+ /**
4552
+ * add SSH JWK and key ID to query params
4553
+ */
4554
+ function addSshJwk(parameters, sshJwkString) {
4555
+ if (sshJwkString) {
4556
+ parameters.set(TOKEN_TYPE, AuthenticationScheme.SSH);
4557
+ parameters.set(REQ_CNF, sshJwkString);
4637
4558
  }
4638
- addBrokerParameters(params) {
4639
- const brokerParams = {};
4640
- brokerParams[BROKER_CLIENT_ID] =
4641
- params.brokerClientId;
4642
- brokerParams[BROKER_REDIRECT_URI] =
4643
- params.brokerRedirectUri;
4644
- this.addExtraQueryParameters(brokerParams);
4559
+ }
4560
+ /**
4561
+ * add server telemetry fields
4562
+ * @param serverTelemetryManager
4563
+ */
4564
+ function addServerTelemetry(parameters, serverTelemetryManager) {
4565
+ parameters.set(X_CLIENT_CURR_TELEM, serverTelemetryManager.generateCurrentRequestHeaderValue());
4566
+ parameters.set(X_CLIENT_LAST_TELEM, serverTelemetryManager.generateLastRequestHeaderValue());
4567
+ }
4568
+ /**
4569
+ * Adds parameter that indicates to the server that throttling is supported
4570
+ */
4571
+ function addThrottling(parameters) {
4572
+ parameters.set(X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);
4573
+ }
4574
+ /**
4575
+ * Adds logout_hint parameter for "silent" logout which prevent server account picker
4576
+ */
4577
+ function addLogoutHint(parameters, logoutHint) {
4578
+ parameters.set(LOGOUT_HINT, logoutHint);
4579
+ }
4580
+ function addBrokerParameters(parameters, brokerClientId, brokerRedirectUri) {
4581
+ if (!parameters.has(BROKER_CLIENT_ID)) {
4582
+ parameters.set(BROKER_CLIENT_ID, brokerClientId);
4645
4583
  }
4646
- /**
4647
- * Utility to create a URL from the params map
4648
- */
4649
- createQueryString() {
4650
- const queryParameterArray = new Array();
4651
- this.parameters.forEach((value, key) => {
4652
- queryParameterArray.push(`${key}=${value}`);
4653
- });
4654
- instrumentBrokerParams(this.parameters, this.correlationId, this.performanceClient);
4655
- return queryParameterArray.join("&");
4584
+ if (!parameters.has(BROKER_REDIRECT_URI)) {
4585
+ parameters.set(BROKER_REDIRECT_URI, brokerRedirectUri);
4656
4586
  }
4657
4587
  }
4658
4588
 
4659
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4589
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
4660
4590
  /*
4661
4591
  * Copyright (c) Microsoft Corporation. All rights reserved.
4662
4592
  * Licensed under the MIT License.
@@ -4668,7 +4598,7 @@ function isOpenIdConfigResponse(response) {
4668
4598
  response.hasOwnProperty("jwks_uri"));
4669
4599
  }
4670
4600
 
4671
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4601
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
4672
4602
  /*
4673
4603
  * Copyright (c) Microsoft Corporation. All rights reserved.
4674
4604
  * Licensed under the MIT License.
@@ -4678,7 +4608,7 @@ function isCloudInstanceDiscoveryResponse(response) {
4678
4608
  response.hasOwnProperty("metadata"));
4679
4609
  }
4680
4610
 
4681
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4611
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
4682
4612
  /*
4683
4613
  * Copyright (c) Microsoft Corporation. All rights reserved.
4684
4614
  * Licensed under the MIT License.
@@ -4688,7 +4618,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
4688
4618
  response.hasOwnProperty("error_description"));
4689
4619
  }
4690
4620
 
4691
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4621
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
4692
4622
  /*
4693
4623
  * Copyright (c) Microsoft Corporation. All rights reserved.
4694
4624
  * Licensed under the MIT License.
@@ -4864,16 +4794,19 @@ const PerformanceEvents = {
4864
4794
  StandardInteractionClientCreateAuthCodeClient: "standardInteractionClientCreateAuthCodeClient",
4865
4795
  StandardInteractionClientGetClientConfiguration: "standardInteractionClientGetClientConfiguration",
4866
4796
  StandardInteractionClientInitializeAuthorizationRequest: "standardInteractionClientInitializeAuthorizationRequest",
4867
- StandardInteractionClientInitializeAuthorizationCodeRequest: "standardInteractionClientInitializeAuthorizationCodeRequest",
4868
4797
  /**
4869
4798
  * getAuthCodeUrl API (msal-browser and msal-node).
4870
4799
  */
4871
4800
  GetAuthCodeUrl: "getAuthCodeUrl",
4801
+ GetStandardParams: "getStandardParams",
4872
4802
  /**
4873
4803
  * Functions from InteractionHandler (msal-browser)
4874
4804
  */
4875
4805
  HandleCodeResponseFromServer: "handleCodeResponseFromServer",
4876
4806
  HandleCodeResponse: "handleCodeResponse",
4807
+ HandleResponseEar: "handleResponseEar",
4808
+ HandleResponsePlatformBroker: "handleResponsePlatformBroker",
4809
+ HandleResponseCode: "handleResponseCode",
4877
4810
  UpdateTokenEndpointAuthority: "updateTokenEndpointAuthority",
4878
4811
  /**
4879
4812
  * APIs in Authorization Code Client (msal-common)
@@ -4881,7 +4814,6 @@ const PerformanceEvents = {
4881
4814
  AuthClientAcquireToken: "authClientAcquireToken",
4882
4815
  AuthClientExecuteTokenRequest: "authClientExecuteTokenRequest",
4883
4816
  AuthClientCreateTokenRequestBody: "authClientCreateTokenRequestBody",
4884
- AuthClientCreateQueryString: "authClientCreateQueryString",
4885
4817
  /**
4886
4818
  * Generate functions in PopTokenGenerator (msal-common)
4887
4819
  */
@@ -4941,9 +4873,11 @@ const PerformanceEvents = {
4941
4873
  UrlEncodeArr: "urlEncodeArr",
4942
4874
  Encrypt: "encrypt",
4943
4875
  Decrypt: "decrypt",
4876
+ GenerateEarKey: "generateEarKey",
4877
+ DecryptEarResponse: "decryptEarResponse",
4944
4878
  };
4945
4879
 
4946
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4880
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
4947
4881
  /*
4948
4882
  * Copyright (c) Microsoft Corporation. All rights reserved.
4949
4883
  * Licensed under the MIT License.
@@ -5039,7 +4973,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
5039
4973
  };
5040
4974
  };
5041
4975
 
5042
- /*! @azure/msal-common v15.2.1 2025-03-11 */
4976
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
5043
4977
 
5044
4978
  /*
5045
4979
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5148,7 +5082,7 @@ RegionDiscovery.IMDS_OPTIONS = {
5148
5082
  },
5149
5083
  };
5150
5084
 
5151
- /*! @azure/msal-common v15.2.1 2025-03-11 */
5085
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
5152
5086
 
5153
5087
  /*
5154
5088
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5326,7 +5260,7 @@ class Authority {
5326
5260
  return (authorityUri.PathSegments.length === 1 &&
5327
5261
  !Authority.reservedTenantDomains.has(authorityUri.PathSegments[0]) &&
5328
5262
  this.getAuthorityType(authorityUri) === AuthorityType.Default &&
5329
- this.protocolMode === ProtocolMode.AAD);
5263
+ this.protocolMode !== ProtocolMode.OIDC);
5330
5264
  }
5331
5265
  /**
5332
5266
  * Replaces tenant in url path with current tenant. Defaults to common.
@@ -5373,7 +5307,7 @@ class Authority {
5373
5307
  const canonicalAuthorityHost = this.hostnameAndPort;
5374
5308
  if (this.canonicalAuthority.endsWith("v2.0/") ||
5375
5309
  this.authorityType === AuthorityType.Adfs ||
5376
- (this.protocolMode !== ProtocolMode.AAD &&
5310
+ (this.protocolMode === ProtocolMode.OIDC &&
5377
5311
  !this.isAliasOfKnownMicrosoftAuthority(canonicalAuthorityHost))) {
5378
5312
  return `${this.canonicalAuthority}.well-known/openid-configuration`;
5379
5313
  }
@@ -5987,7 +5921,7 @@ function buildStaticAuthorityOptions(authOptions) {
5987
5921
  };
5988
5922
  }
5989
5923
 
5990
- /*! @azure/msal-common v15.2.1 2025-03-11 */
5924
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
5991
5925
 
5992
5926
  /*
5993
5927
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6018,7 +5952,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
6018
5952
  }
6019
5953
  }
6020
5954
 
6021
- /*! @azure/msal-common v15.2.1 2025-03-11 */
5955
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6022
5956
 
6023
5957
  /*
6024
5958
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6037,7 +5971,7 @@ class ServerError extends AuthError {
6037
5971
  }
6038
5972
  }
6039
5973
 
6040
- /*! @azure/msal-common v15.2.1 2025-03-11 */
5974
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6041
5975
  /*
6042
5976
  * Copyright (c) Microsoft Corporation. All rights reserved.
6043
5977
  * Licensed under the MIT License.
@@ -6058,7 +5992,7 @@ function getRequestThumbprint(clientId, request, homeAccountId) {
6058
5992
  };
6059
5993
  }
6060
5994
 
6061
- /*! @azure/msal-common v15.2.1 2025-03-11 */
5995
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6062
5996
 
6063
5997
  /*
6064
5998
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6145,7 +6079,7 @@ class ThrottlingUtils {
6145
6079
  }
6146
6080
  }
6147
6081
 
6148
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6082
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6149
6083
 
6150
6084
  /*
6151
6085
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6165,7 +6099,7 @@ class NetworkError extends AuthError {
6165
6099
  }
6166
6100
  }
6167
6101
 
6168
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6102
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6169
6103
 
6170
6104
  /*
6171
6105
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6300,22 +6234,20 @@ class BaseClient {
6300
6234
  * @param request
6301
6235
  */
6302
6236
  createTokenQueryParameters(request) {
6303
- const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
6237
+ const parameters = new Map();
6304
6238
  if (request.embeddedClientId) {
6305
- parameterBuilder.addBrokerParameters({
6306
- brokerClientId: this.config.authOptions.clientId,
6307
- brokerRedirectUri: this.config.authOptions.redirectUri,
6308
- });
6239
+ addBrokerParameters(parameters, this.config.authOptions.clientId, this.config.authOptions.redirectUri);
6309
6240
  }
6310
6241
  if (request.tokenQueryParameters) {
6311
- parameterBuilder.addExtraQueryParameters(request.tokenQueryParameters);
6242
+ addExtraQueryParameters(parameters, request.tokenQueryParameters);
6312
6243
  }
6313
- parameterBuilder.addCorrelationId(request.correlationId);
6314
- return parameterBuilder.createQueryString();
6244
+ addCorrelationId(parameters, request.correlationId);
6245
+ instrumentBrokerParams(parameters, request.correlationId, this.performanceClient);
6246
+ return mapToQueryString(parameters);
6315
6247
  }
6316
6248
  }
6317
6249
 
6318
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6250
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6319
6251
  /*
6320
6252
  * Copyright (c) Microsoft Corporation. All rights reserved.
6321
6253
  * Licensed under the MIT License.
@@ -6341,7 +6273,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6341
6273
  refreshTokenExpired: refreshTokenExpired
6342
6274
  });
6343
6275
 
6344
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6276
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6345
6277
 
6346
6278
  /*
6347
6279
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6429,7 +6361,7 @@ function createInteractionRequiredAuthError(errorCode) {
6429
6361
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6430
6362
  }
6431
6363
 
6432
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6364
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6433
6365
 
6434
6366
  /*
6435
6367
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6501,7 +6433,7 @@ class ProtocolUtils {
6501
6433
  }
6502
6434
  }
6503
6435
 
6504
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6436
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6505
6437
 
6506
6438
  /*
6507
6439
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6585,7 +6517,7 @@ class PopTokenGenerator {
6585
6517
  }
6586
6518
  }
6587
6519
 
6588
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6520
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6589
6521
  /*
6590
6522
  * Copyright (c) Microsoft Corporation. All rights reserved.
6591
6523
  * Licensed under the MIT License.
@@ -6612,19 +6544,12 @@ class PopTokenGenerator {
6612
6544
  }
6613
6545
  }
6614
6546
 
6615
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6547
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6616
6548
 
6617
6549
  /*
6618
6550
  * Copyright (c) Microsoft Corporation. All rights reserved.
6619
6551
  * Licensed under the MIT License.
6620
6552
  */
6621
- function parseServerErrorNo(serverResponse) {
6622
- const errorCodePrefix = "code=";
6623
- const errorCodePrefixIndex = serverResponse.error_uri?.lastIndexOf(errorCodePrefix);
6624
- return errorCodePrefixIndex && errorCodePrefixIndex >= 0
6625
- ? serverResponse.error_uri?.substring(errorCodePrefixIndex + errorCodePrefix.length)
6626
- : undefined;
6627
- }
6628
6553
  /**
6629
6554
  * Class that handles response parsing.
6630
6555
  * @internal
@@ -6639,46 +6564,6 @@ class ResponseHandler {
6639
6564
  this.persistencePlugin = persistencePlugin;
6640
6565
  this.performanceClient = performanceClient;
6641
6566
  }
6642
- /**
6643
- * Function which validates server authorization code response.
6644
- * @param serverResponseHash
6645
- * @param requestState
6646
- * @param cryptoObj
6647
- */
6648
- validateServerAuthorizationCodeResponse(serverResponse, requestState) {
6649
- if (!serverResponse.state || !requestState) {
6650
- throw serverResponse.state
6651
- ? createClientAuthError(stateNotFound, "Cached State")
6652
- : createClientAuthError(stateNotFound, "Server State");
6653
- }
6654
- let decodedServerResponseState;
6655
- let decodedRequestState;
6656
- try {
6657
- decodedServerResponseState = decodeURIComponent(serverResponse.state);
6658
- }
6659
- catch (e) {
6660
- throw createClientAuthError(invalidState, serverResponse.state);
6661
- }
6662
- try {
6663
- decodedRequestState = decodeURIComponent(requestState);
6664
- }
6665
- catch (e) {
6666
- throw createClientAuthError(invalidState, serverResponse.state);
6667
- }
6668
- if (decodedServerResponseState !== decodedRequestState) {
6669
- throw createClientAuthError(stateMismatch);
6670
- }
6671
- // Check for error
6672
- if (serverResponse.error ||
6673
- serverResponse.error_description ||
6674
- serverResponse.suberror) {
6675
- const serverErrorNo = parseServerErrorNo(serverResponse);
6676
- if (isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
6677
- throw new InteractionRequiredAuthError(serverResponse.error || "", serverResponse.error_description, serverResponse.suberror, serverResponse.timestamp || "", serverResponse.trace_id || "", serverResponse.correlation_id || "", serverResponse.claims || "", serverErrorNo);
6678
- }
6679
- throw new ServerError(serverResponse.error || "", serverResponse.error_description, serverResponse.suberror, serverErrorNo);
6680
- }
6681
- }
6682
6567
  /**
6683
6568
  * Function which validates server authorization token response.
6684
6569
  * @param serverResponse
@@ -6990,7 +6875,74 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
6990
6875
  return baseAccount;
6991
6876
  }
6992
6877
 
6993
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6878
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6879
+
6880
+ /*
6881
+ * Copyright (c) Microsoft Corporation. All rights reserved.
6882
+ * Licensed under the MIT License.
6883
+ */
6884
+ /**
6885
+ * Validates server consumable params from the "request" objects
6886
+ */
6887
+ class RequestValidator {
6888
+ /**
6889
+ * Utility to check if the `redirectUri` in the request is a non-null value
6890
+ * @param redirectUri
6891
+ */
6892
+ static validateRedirectUri(redirectUri) {
6893
+ if (!redirectUri) {
6894
+ throw createClientConfigurationError(redirectUriEmpty);
6895
+ }
6896
+ }
6897
+ /**
6898
+ * Utility to validate prompt sent by the user in the request
6899
+ * @param prompt
6900
+ */
6901
+ static validatePrompt(prompt) {
6902
+ const promptValues = [];
6903
+ for (const value in PromptValue) {
6904
+ promptValues.push(PromptValue[value]);
6905
+ }
6906
+ if (promptValues.indexOf(prompt) < 0) {
6907
+ throw createClientConfigurationError(invalidPromptValue);
6908
+ }
6909
+ }
6910
+ static validateClaims(claims) {
6911
+ try {
6912
+ JSON.parse(claims);
6913
+ }
6914
+ catch (e) {
6915
+ throw createClientConfigurationError(invalidClaims);
6916
+ }
6917
+ }
6918
+ /**
6919
+ * Utility to validate code_challenge and code_challenge_method
6920
+ * @param codeChallenge
6921
+ * @param codeChallengeMethod
6922
+ */
6923
+ static validateCodeChallengeParams(codeChallenge, codeChallengeMethod) {
6924
+ if (!codeChallenge || !codeChallengeMethod) {
6925
+ throw createClientConfigurationError(pkceParamsMissing);
6926
+ }
6927
+ else {
6928
+ this.validateCodeChallengeMethod(codeChallengeMethod);
6929
+ }
6930
+ }
6931
+ /**
6932
+ * Utility to validate code_challenge_method
6933
+ * @param codeChallengeMethod
6934
+ */
6935
+ static validateCodeChallengeMethod(codeChallengeMethod) {
6936
+ if ([
6937
+ CodeChallengeMethodValues.PLAIN,
6938
+ CodeChallengeMethodValues.S256,
6939
+ ].indexOf(codeChallengeMethod) < 0) {
6940
+ throw createClientConfigurationError(invalidCodeChallengeMethod);
6941
+ }
6942
+ }
6943
+ }
6944
+
6945
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
6994
6946
  /*
6995
6947
  * Copyright (c) Microsoft Corporation. All rights reserved.
6996
6948
  * Licensed under the MIT License.
@@ -7008,7 +6960,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
7008
6960
  }
7009
6961
  }
7010
6962
 
7011
- /*! @azure/msal-common v15.2.1 2025-03-11 */
6963
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
7012
6964
 
7013
6965
  /*
7014
6966
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7026,21 +6978,6 @@ class AuthorizationCodeClient extends BaseClient {
7026
6978
  this.oidcDefaultScopes =
7027
6979
  this.config.authOptions.authority.options.OIDCOptions?.defaultScopes;
7028
6980
  }
7029
- /**
7030
- * Creates the URL of the authorization request letting the user input credentials and consent to the
7031
- * application. The URL target the /authorize endpoint of the authority configured in the
7032
- * application object.
7033
- *
7034
- * Once the user inputs their credentials and consents, the authority will send a response to the redirect URI
7035
- * sent in the request and should contain an authorization code, which can then be used to acquire tokens via
7036
- * acquireToken(AuthorizationCodeRequest)
7037
- * @param request
7038
- */
7039
- async getAuthCodeUrl(request) {
7040
- this.performanceClient?.addQueueMeasurement(PerformanceEvents.GetAuthCodeUrl, request.correlationId);
7041
- const queryString = await invokeAsync(this.createAuthCodeUrlQueryString.bind(this), PerformanceEvents.AuthClientCreateQueryString, this.logger, this.performanceClient, request.correlationId)(request);
7042
- return UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString);
7043
- }
7044
6981
  /**
7045
6982
  * API to acquire a token in exchange of 'authorization_code` acquired by the user in the first leg of the
7046
6983
  * authorization_code_grant
@@ -7060,22 +6997,6 @@ class AuthorizationCodeClient extends BaseClient {
7060
6997
  responseHandler.validateTokenResponse(response.body);
7061
6998
  return invokeAsync(responseHandler.handleServerTokenResponse.bind(responseHandler), PerformanceEvents.HandleServerTokenResponse, this.logger, this.performanceClient, request.correlationId)(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId);
7062
6999
  }
7063
- /**
7064
- * Handles the hash fragment response from public client code request. Returns a code response used by
7065
- * the client to exchange for a token in acquireToken.
7066
- * @param hashFragment
7067
- */
7068
- handleFragmentResponse(serverParams, cachedState) {
7069
- // Handle responses.
7070
- const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, null, null);
7071
- // Get code response
7072
- responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState);
7073
- // throw when there is no auth code in the response
7074
- if (!serverParams.code) {
7075
- throw createClientAuthError(authorizationCodeMissingFromServerResponse);
7076
- }
7077
- return serverParams;
7078
- }
7079
7000
  /**
7080
7001
  * Used to log out the current user, and redirect the user to the postLogoutRedirectUri.
7081
7002
  * Default behaviour is to redirect the user to `window.location.href`.
@@ -7123,8 +7044,8 @@ class AuthorizationCodeClient extends BaseClient {
7123
7044
  */
7124
7045
  async createTokenRequestBody(request) {
7125
7046
  this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
7126
- const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
7127
- parameterBuilder.addClientId(request.embeddedClientId ||
7047
+ const parameters = new Map();
7048
+ addClientId(parameters, request.embeddedClientId ||
7128
7049
  request.tokenBodyParameters?.[CLIENT_ID] ||
7129
7050
  this.config.authOptions.clientId);
7130
7051
  /*
@@ -7137,33 +7058,33 @@ class AuthorizationCodeClient extends BaseClient {
7137
7058
  }
7138
7059
  else {
7139
7060
  // Validate and include redirect uri
7140
- parameterBuilder.addRedirectUri(request.redirectUri);
7061
+ addRedirectUri(parameters, request.redirectUri);
7141
7062
  }
7142
7063
  // Add scope array, parameter builder will add default scopes and dedupe
7143
- parameterBuilder.addScopes(request.scopes, true, this.oidcDefaultScopes);
7064
+ addScopes(parameters, request.scopes, true, this.oidcDefaultScopes);
7144
7065
  // add code: user set, not validated
7145
- parameterBuilder.addAuthorizationCode(request.code);
7066
+ addAuthorizationCode(parameters, request.code);
7146
7067
  // Add library metadata
7147
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
7148
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
7149
- parameterBuilder.addThrottling();
7068
+ addLibraryInfo(parameters, this.config.libraryInfo);
7069
+ addApplicationTelemetry(parameters, this.config.telemetry.application);
7070
+ addThrottling(parameters);
7150
7071
  if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
7151
- parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
7072
+ addServerTelemetry(parameters, this.serverTelemetryManager);
7152
7073
  }
7153
7074
  // add code_verifier if passed
7154
7075
  if (request.codeVerifier) {
7155
- parameterBuilder.addCodeVerifier(request.codeVerifier);
7076
+ addCodeVerifier(parameters, request.codeVerifier);
7156
7077
  }
7157
7078
  if (this.config.clientCredentials.clientSecret) {
7158
- parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
7079
+ addClientSecret(parameters, this.config.clientCredentials.clientSecret);
7159
7080
  }
7160
7081
  if (this.config.clientCredentials.clientAssertion) {
7161
7082
  const clientAssertion = this.config.clientCredentials.clientAssertion;
7162
- parameterBuilder.addClientAssertion(await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
7163
- parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
7083
+ addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
7084
+ addClientAssertionType(parameters, clientAssertion.assertionType);
7164
7085
  }
7165
- parameterBuilder.addGrantType(GrantType.AUTHORIZATION_CODE_GRANT);
7166
- parameterBuilder.addClientInfo();
7086
+ addGrantType(parameters, GrantType.AUTHORIZATION_CODE_GRANT);
7087
+ addClientInfo(parameters);
7167
7088
  if (request.authenticationScheme === AuthenticationScheme.POP) {
7168
7089
  const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
7169
7090
  let reqCnfData;
@@ -7175,11 +7096,11 @@ class AuthorizationCodeClient extends BaseClient {
7175
7096
  reqCnfData = this.cryptoUtils.encodeKid(request.popKid);
7176
7097
  }
7177
7098
  // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
7178
- parameterBuilder.addPopToken(reqCnfData);
7099
+ addPopToken(parameters, reqCnfData);
7179
7100
  }
7180
7101
  else if (request.authenticationScheme === AuthenticationScheme.SSH) {
7181
7102
  if (request.sshJwk) {
7182
- parameterBuilder.addSshJwk(request.sshJwk);
7103
+ addSshJwk(parameters, request.sshJwk);
7183
7104
  }
7184
7105
  else {
7185
7106
  throw createClientConfigurationError(missingSshJwk);
@@ -7188,7 +7109,7 @@ class AuthorizationCodeClient extends BaseClient {
7188
7109
  if (!StringUtils.isEmptyObj(request.claims) ||
7189
7110
  (this.config.authOptions.clientCapabilities &&
7190
7111
  this.config.authOptions.clientCapabilities.length > 0)) {
7191
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
7112
+ addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
7192
7113
  }
7193
7114
  let ccsCred = undefined;
7194
7115
  if (request.clientInfo) {
@@ -7212,7 +7133,7 @@ class AuthorizationCodeClient extends BaseClient {
7212
7133
  case CcsCredentialType.HOME_ACCOUNT_ID:
7213
7134
  try {
7214
7135
  const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
7215
- parameterBuilder.addCcsOid(clientInfo);
7136
+ addCcsOid(parameters, clientInfo);
7216
7137
  }
7217
7138
  catch (e) {
7218
7139
  this.logger.verbose("Could not parse home account ID for CCS Header: " +
@@ -7220,234 +7141,59 @@ class AuthorizationCodeClient extends BaseClient {
7220
7141
  }
7221
7142
  break;
7222
7143
  case CcsCredentialType.UPN:
7223
- parameterBuilder.addCcsUpn(ccsCred.credential);
7144
+ addCcsUpn(parameters, ccsCred.credential);
7224
7145
  break;
7225
7146
  }
7226
7147
  }
7227
7148
  if (request.embeddedClientId) {
7228
- parameterBuilder.addBrokerParameters({
7229
- brokerClientId: this.config.authOptions.clientId,
7230
- brokerRedirectUri: this.config.authOptions.redirectUri,
7231
- });
7149
+ addBrokerParameters(parameters, this.config.authOptions.clientId, this.config.authOptions.redirectUri);
7232
7150
  }
7233
7151
  if (request.tokenBodyParameters) {
7234
- parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
7152
+ addExtraQueryParameters(parameters, request.tokenBodyParameters);
7235
7153
  }
7236
7154
  // Add hybrid spa parameters if not already provided
7237
7155
  if (request.enableSpaAuthorizationCode &&
7238
7156
  (!request.tokenBodyParameters ||
7239
7157
  !request.tokenBodyParameters[RETURN_SPA_CODE])) {
7240
- parameterBuilder.addExtraQueryParameters({
7158
+ addExtraQueryParameters(parameters, {
7241
7159
  [RETURN_SPA_CODE]: "1",
7242
7160
  });
7243
7161
  }
7244
- return parameterBuilder.createQueryString();
7245
- }
7246
- /**
7247
- * This API validates the `AuthorizationCodeUrlRequest` and creates a URL
7248
- * @param request
7249
- */
7250
- async createAuthCodeUrlQueryString(request) {
7251
- // generate the correlationId if not set by the user and add
7252
- const correlationId = request.correlationId ||
7253
- this.config.cryptoInterface.createNewGuid();
7254
- this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateQueryString, correlationId);
7255
- const parameterBuilder = new RequestParameterBuilder(correlationId, this.performanceClient);
7256
- parameterBuilder.addClientId(request.embeddedClientId ||
7257
- request.extraQueryParameters?.[CLIENT_ID] ||
7258
- this.config.authOptions.clientId);
7259
- const requestScopes = [
7260
- ...(request.scopes || []),
7261
- ...(request.extraScopesToConsent || []),
7262
- ];
7263
- parameterBuilder.addScopes(requestScopes, true, this.oidcDefaultScopes);
7264
- // validate the redirectUri (to be a non null value)
7265
- parameterBuilder.addRedirectUri(request.redirectUri);
7266
- parameterBuilder.addCorrelationId(correlationId);
7267
- // add response_mode. If not passed in it defaults to query.
7268
- parameterBuilder.addResponseMode(request.responseMode);
7269
- // add response_type = code
7270
- parameterBuilder.addResponseTypeCode();
7271
- // add library info parameters
7272
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
7273
- if (!isOidcProtocolMode(this.config)) {
7274
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
7275
- }
7276
- // add client_info=1
7277
- parameterBuilder.addClientInfo();
7278
- if (request.codeChallenge && request.codeChallengeMethod) {
7279
- parameterBuilder.addCodeChallengeParams(request.codeChallenge, request.codeChallengeMethod);
7280
- }
7281
- if (request.prompt) {
7282
- parameterBuilder.addPrompt(request.prompt);
7283
- }
7284
- if (request.domainHint) {
7285
- parameterBuilder.addDomainHint(request.domainHint);
7286
- this.performanceClient?.addFields({ domainHintFromRequest: true }, correlationId);
7287
- }
7288
- this.performanceClient?.addFields({ prompt: request.prompt }, correlationId);
7289
- // Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
7290
- if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
7291
- // AAD will throw if prompt=select_account is passed with an account hint
7292
- if (request.sid && request.prompt === PromptValue.NONE) {
7293
- // SessionID is only used in silent calls
7294
- this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from request");
7295
- parameterBuilder.addSid(request.sid);
7296
- this.performanceClient?.addFields({ sidFromRequest: true }, correlationId);
7297
- }
7298
- else if (request.account) {
7299
- const accountSid = this.extractAccountSid(request.account);
7300
- let accountLoginHintClaim = this.extractLoginHint(request.account);
7301
- if (accountLoginHintClaim && request.domainHint) {
7302
- this.logger.warning(`AuthorizationCodeClient.createAuthCodeUrlQueryString: "domainHint" param is set, skipping opaque "login_hint" claim. Please consider not passing domainHint`);
7303
- accountLoginHintClaim = null;
7304
- }
7305
- // If login_hint claim is present, use it over sid/username
7306
- if (accountLoginHintClaim) {
7307
- this.logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
7308
- parameterBuilder.addLoginHint(accountLoginHintClaim);
7309
- this.performanceClient?.addFields({ loginHintFromClaim: true }, correlationId);
7310
- try {
7311
- const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
7312
- parameterBuilder.addCcsOid(clientInfo);
7313
- }
7314
- catch (e) {
7315
- this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
7316
- }
7317
- }
7318
- else if (accountSid && request.prompt === PromptValue.NONE) {
7319
- /*
7320
- * If account and loginHint are provided, we will check account first for sid before adding loginHint
7321
- * SessionId is only used in silent calls
7322
- */
7323
- this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
7324
- parameterBuilder.addSid(accountSid);
7325
- this.performanceClient?.addFields({ sidFromClaim: true }, correlationId);
7326
- try {
7327
- const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
7328
- parameterBuilder.addCcsOid(clientInfo);
7329
- }
7330
- catch (e) {
7331
- this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
7332
- }
7333
- }
7334
- else if (request.loginHint) {
7335
- this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from request");
7336
- parameterBuilder.addLoginHint(request.loginHint);
7337
- parameterBuilder.addCcsUpn(request.loginHint);
7338
- this.performanceClient?.addFields({ loginHintFromRequest: true }, correlationId);
7339
- }
7340
- else if (request.account.username) {
7341
- // Fallback to account username if provided
7342
- this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account");
7343
- parameterBuilder.addLoginHint(request.account.username);
7344
- this.performanceClient?.addFields({ loginHintFromUpn: true }, correlationId);
7345
- try {
7346
- const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
7347
- parameterBuilder.addCcsOid(clientInfo);
7348
- }
7349
- catch (e) {
7350
- this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
7351
- }
7352
- }
7353
- }
7354
- else if (request.loginHint) {
7355
- this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
7356
- parameterBuilder.addLoginHint(request.loginHint);
7357
- parameterBuilder.addCcsUpn(request.loginHint);
7358
- this.performanceClient?.addFields({ loginHintFromRequest: true }, correlationId);
7359
- }
7360
- }
7361
- else {
7362
- this.logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
7363
- }
7364
- if (request.nonce) {
7365
- parameterBuilder.addNonce(request.nonce);
7366
- }
7367
- if (request.state) {
7368
- parameterBuilder.addState(request.state);
7369
- }
7370
- if (request.claims ||
7371
- (this.config.authOptions.clientCapabilities &&
7372
- this.config.authOptions.clientCapabilities.length > 0)) {
7373
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
7374
- }
7375
- if (request.embeddedClientId) {
7376
- parameterBuilder.addBrokerParameters({
7377
- brokerClientId: this.config.authOptions.clientId,
7378
- brokerRedirectUri: this.config.authOptions.redirectUri,
7379
- });
7380
- }
7381
- this.addExtraQueryParams(request, parameterBuilder);
7382
- if (request.platformBroker) {
7383
- // signal ests that this is a WAM call
7384
- parameterBuilder.addNativeBroker();
7385
- // pass the req_cnf for POP
7386
- if (request.authenticationScheme === AuthenticationScheme.POP) {
7387
- const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
7388
- // req_cnf is always sent as a string for SPAs
7389
- let reqCnfData;
7390
- if (!request.popKid) {
7391
- const generatedReqCnfData = await invokeAsync(popTokenGenerator.generateCnf.bind(popTokenGenerator), PerformanceEvents.PopTokenGenerateCnf, this.logger, this.performanceClient, request.correlationId)(request, this.logger);
7392
- reqCnfData = generatedReqCnfData.reqCnfString;
7393
- }
7394
- else {
7395
- reqCnfData = this.cryptoUtils.encodeKid(request.popKid);
7396
- }
7397
- parameterBuilder.addPopToken(reqCnfData);
7398
- }
7399
- }
7400
- return parameterBuilder.createQueryString();
7162
+ instrumentBrokerParams(parameters, request.correlationId, this.performanceClient);
7163
+ return mapToQueryString(parameters);
7401
7164
  }
7402
7165
  /**
7403
7166
  * This API validates the `EndSessionRequest` and creates a URL
7404
7167
  * @param request
7405
7168
  */
7406
7169
  createLogoutUrlQueryString(request) {
7407
- const parameterBuilder = new RequestParameterBuilder(request.correlationId, this.performanceClient);
7170
+ const parameters = new Map();
7408
7171
  if (request.postLogoutRedirectUri) {
7409
- parameterBuilder.addPostLogoutRedirectUri(request.postLogoutRedirectUri);
7172
+ addPostLogoutRedirectUri(parameters, request.postLogoutRedirectUri);
7410
7173
  }
7411
7174
  if (request.correlationId) {
7412
- parameterBuilder.addCorrelationId(request.correlationId);
7175
+ addCorrelationId(parameters, request.correlationId);
7413
7176
  }
7414
7177
  if (request.idTokenHint) {
7415
- parameterBuilder.addIdTokenHint(request.idTokenHint);
7178
+ addIdTokenHint(parameters, request.idTokenHint);
7416
7179
  }
7417
7180
  if (request.state) {
7418
- parameterBuilder.addState(request.state);
7181
+ addState(parameters, request.state);
7419
7182
  }
7420
7183
  if (request.logoutHint) {
7421
- parameterBuilder.addLogoutHint(request.logoutHint);
7422
- }
7423
- this.addExtraQueryParams(request, parameterBuilder);
7424
- return parameterBuilder.createQueryString();
7425
- }
7426
- addExtraQueryParams(request, parameterBuilder) {
7427
- const hasRequestInstanceAware = request.extraQueryParameters &&
7428
- request.extraQueryParameters.hasOwnProperty("instance_aware");
7429
- // Set instance_aware flag if config auth param is set
7430
- if (!hasRequestInstanceAware && this.config.authOptions.instanceAware) {
7431
- request.extraQueryParameters = request.extraQueryParameters || {};
7432
- request.extraQueryParameters["instance_aware"] = "true";
7184
+ addLogoutHint(parameters, request.logoutHint);
7433
7185
  }
7434
7186
  if (request.extraQueryParameters) {
7435
- parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
7187
+ addExtraQueryParameters(parameters, request.extraQueryParameters);
7436
7188
  }
7437
- }
7438
- /**
7439
- * Helper to get sid from account. Returns null if idTokenClaims are not present or sid is not present.
7440
- * @param account
7441
- */
7442
- extractAccountSid(account) {
7443
- return account.idTokenClaims?.sid || null;
7444
- }
7445
- extractLoginHint(account) {
7446
- return account.idTokenClaims?.login_hint || null;
7189
+ if (this.config.authOptions.instanceAware) {
7190
+ addInstanceAware(parameters);
7191
+ }
7192
+ return mapToQueryString(parameters);
7447
7193
  }
7448
7194
  }
7449
7195
 
7450
- /*! @azure/msal-common v15.2.1 2025-03-11 */
7196
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
7451
7197
 
7452
7198
  /*
7453
7199
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7576,31 +7322,30 @@ class RefreshTokenClient extends BaseClient {
7576
7322
  */
7577
7323
  async createTokenRequestBody(request) {
7578
7324
  this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
7579
- const correlationId = request.correlationId;
7580
- const parameterBuilder = new RequestParameterBuilder(correlationId, this.performanceClient);
7581
- parameterBuilder.addClientId(request.embeddedClientId ||
7325
+ const parameters = new Map();
7326
+ addClientId(parameters, request.embeddedClientId ||
7582
7327
  request.tokenBodyParameters?.[CLIENT_ID] ||
7583
7328
  this.config.authOptions.clientId);
7584
7329
  if (request.redirectUri) {
7585
- parameterBuilder.addRedirectUri(request.redirectUri);
7586
- }
7587
- parameterBuilder.addScopes(request.scopes, true, this.config.authOptions.authority.options.OIDCOptions?.defaultScopes);
7588
- parameterBuilder.addGrantType(GrantType.REFRESH_TOKEN_GRANT);
7589
- parameterBuilder.addClientInfo();
7590
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
7591
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
7592
- parameterBuilder.addThrottling();
7330
+ addRedirectUri(parameters, request.redirectUri);
7331
+ }
7332
+ addScopes(parameters, request.scopes, true, this.config.authOptions.authority.options.OIDCOptions?.defaultScopes);
7333
+ addGrantType(parameters, GrantType.REFRESH_TOKEN_GRANT);
7334
+ addClientInfo(parameters);
7335
+ addLibraryInfo(parameters, this.config.libraryInfo);
7336
+ addApplicationTelemetry(parameters, this.config.telemetry.application);
7337
+ addThrottling(parameters);
7593
7338
  if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
7594
- parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
7339
+ addServerTelemetry(parameters, this.serverTelemetryManager);
7595
7340
  }
7596
- parameterBuilder.addRefreshToken(request.refreshToken);
7341
+ addRefreshToken(parameters, request.refreshToken);
7597
7342
  if (this.config.clientCredentials.clientSecret) {
7598
- parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
7343
+ addClientSecret(parameters, this.config.clientCredentials.clientSecret);
7599
7344
  }
7600
7345
  if (this.config.clientCredentials.clientAssertion) {
7601
7346
  const clientAssertion = this.config.clientCredentials.clientAssertion;
7602
- parameterBuilder.addClientAssertion(await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
7603
- parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
7347
+ addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
7348
+ addClientAssertionType(parameters, clientAssertion.assertionType);
7604
7349
  }
7605
7350
  if (request.authenticationScheme === AuthenticationScheme.POP) {
7606
7351
  const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
@@ -7613,11 +7358,11 @@ class RefreshTokenClient extends BaseClient {
7613
7358
  reqCnfData = this.cryptoUtils.encodeKid(request.popKid);
7614
7359
  }
7615
7360
  // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
7616
- parameterBuilder.addPopToken(reqCnfData);
7361
+ addPopToken(parameters, reqCnfData);
7617
7362
  }
7618
7363
  else if (request.authenticationScheme === AuthenticationScheme.SSH) {
7619
7364
  if (request.sshJwk) {
7620
- parameterBuilder.addSshJwk(request.sshJwk);
7365
+ addSshJwk(parameters, request.sshJwk);
7621
7366
  }
7622
7367
  else {
7623
7368
  throw createClientConfigurationError(missingSshJwk);
@@ -7626,7 +7371,7 @@ class RefreshTokenClient extends BaseClient {
7626
7371
  if (!StringUtils.isEmptyObj(request.claims) ||
7627
7372
  (this.config.authOptions.clientCapabilities &&
7628
7373
  this.config.authOptions.clientCapabilities.length > 0)) {
7629
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
7374
+ addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
7630
7375
  }
7631
7376
  if (this.config.systemOptions.preventCorsPreflight &&
7632
7377
  request.ccsCredential) {
@@ -7634,7 +7379,7 @@ class RefreshTokenClient extends BaseClient {
7634
7379
  case CcsCredentialType.HOME_ACCOUNT_ID:
7635
7380
  try {
7636
7381
  const clientInfo = buildClientInfoFromHomeAccountId(request.ccsCredential.credential);
7637
- parameterBuilder.addCcsOid(clientInfo);
7382
+ addCcsOid(parameters, clientInfo);
7638
7383
  }
7639
7384
  catch (e) {
7640
7385
  this.logger.verbose("Could not parse home account ID for CCS Header: " +
@@ -7642,24 +7387,22 @@ class RefreshTokenClient extends BaseClient {
7642
7387
  }
7643
7388
  break;
7644
7389
  case CcsCredentialType.UPN:
7645
- parameterBuilder.addCcsUpn(request.ccsCredential.credential);
7390
+ addCcsUpn(parameters, request.ccsCredential.credential);
7646
7391
  break;
7647
7392
  }
7648
7393
  }
7649
7394
  if (request.embeddedClientId) {
7650
- parameterBuilder.addBrokerParameters({
7651
- brokerClientId: this.config.authOptions.clientId,
7652
- brokerRedirectUri: this.config.authOptions.redirectUri,
7653
- });
7395
+ addBrokerParameters(parameters, this.config.authOptions.clientId, this.config.authOptions.redirectUri);
7654
7396
  }
7655
7397
  if (request.tokenBodyParameters) {
7656
- parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
7398
+ addExtraQueryParameters(parameters, request.tokenBodyParameters);
7657
7399
  }
7658
- return parameterBuilder.createQueryString();
7400
+ instrumentBrokerParams(parameters, request.correlationId, this.performanceClient);
7401
+ return mapToQueryString(parameters);
7659
7402
  }
7660
7403
  }
7661
7404
 
7662
- /*! @azure/msal-common v15.2.1 2025-03-11 */
7405
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
7663
7406
 
7664
7407
  /*
7665
7408
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7757,7 +7500,157 @@ class SilentFlowClient extends BaseClient {
7757
7500
  }
7758
7501
  }
7759
7502
 
7760
- /*! @azure/msal-common v15.2.1 2025-03-11 */
7503
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
7504
+
7505
+ /*
7506
+ * Copyright (c) Microsoft Corporation. All rights reserved.
7507
+ * Licensed under the MIT License.
7508
+ */
7509
+ /**
7510
+ * Returns map of parameters that are applicable to all calls to /authorize whether using PKCE or EAR
7511
+ * @param config
7512
+ * @param request
7513
+ * @param logger
7514
+ * @param performanceClient
7515
+ * @returns
7516
+ */
7517
+ function getStandardAuthorizeRequestParameters(authOptions, request, logger, performanceClient) {
7518
+ // generate the correlationId if not set by the user and add
7519
+ const correlationId = request.correlationId;
7520
+ const parameters = new Map();
7521
+ addClientId(parameters, request.embeddedClientId ||
7522
+ request.extraQueryParameters?.[CLIENT_ID] ||
7523
+ authOptions.clientId);
7524
+ const requestScopes = [
7525
+ ...(request.scopes || []),
7526
+ ...(request.extraScopesToConsent || []),
7527
+ ];
7528
+ addScopes(parameters, requestScopes, true, authOptions.authority.options.OIDCOptions?.defaultScopes);
7529
+ addRedirectUri(parameters, request.redirectUri);
7530
+ addCorrelationId(parameters, correlationId);
7531
+ // add response_mode. If not passed in it defaults to query.
7532
+ addResponseMode(parameters, request.responseMode);
7533
+ // add client_info=1
7534
+ addClientInfo(parameters);
7535
+ if (request.prompt) {
7536
+ addPrompt(parameters, request.prompt);
7537
+ }
7538
+ if (request.domainHint) {
7539
+ addDomainHint(parameters, request.domainHint);
7540
+ }
7541
+ // Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
7542
+ if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
7543
+ // AAD will throw if prompt=select_account is passed with an account hint
7544
+ if (request.sid && request.prompt === PromptValue.NONE) {
7545
+ // SessionID is only used in silent calls
7546
+ logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from request");
7547
+ addSid(parameters, request.sid);
7548
+ }
7549
+ else if (request.account) {
7550
+ const accountSid = extractAccountSid(request.account);
7551
+ let accountLoginHintClaim = extractLoginHint(request.account);
7552
+ if (accountLoginHintClaim && request.domainHint) {
7553
+ logger.warning(`AuthorizationCodeClient.createAuthCodeUrlQueryString: "domainHint" param is set, skipping opaque "login_hint" claim. Please consider not passing domainHint`);
7554
+ accountLoginHintClaim = null;
7555
+ }
7556
+ // If login_hint claim is present, use it over sid/username
7557
+ if (accountLoginHintClaim) {
7558
+ logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
7559
+ addLoginHint(parameters, accountLoginHintClaim);
7560
+ try {
7561
+ const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
7562
+ addCcsOid(parameters, clientInfo);
7563
+ }
7564
+ catch (e) {
7565
+ logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
7566
+ }
7567
+ }
7568
+ else if (accountSid && request.prompt === PromptValue.NONE) {
7569
+ /*
7570
+ * If account and loginHint are provided, we will check account first for sid before adding loginHint
7571
+ * SessionId is only used in silent calls
7572
+ */
7573
+ logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
7574
+ addSid(parameters, accountSid);
7575
+ try {
7576
+ const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
7577
+ addCcsOid(parameters, clientInfo);
7578
+ }
7579
+ catch (e) {
7580
+ logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
7581
+ }
7582
+ }
7583
+ else if (request.loginHint) {
7584
+ logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from request");
7585
+ addLoginHint(parameters, request.loginHint);
7586
+ addCcsUpn(parameters, request.loginHint);
7587
+ }
7588
+ else if (request.account.username) {
7589
+ // Fallback to account username if provided
7590
+ logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account");
7591
+ addLoginHint(parameters, request.account.username);
7592
+ try {
7593
+ const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
7594
+ addCcsOid(parameters, clientInfo);
7595
+ }
7596
+ catch (e) {
7597
+ logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
7598
+ }
7599
+ }
7600
+ }
7601
+ else if (request.loginHint) {
7602
+ logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
7603
+ addLoginHint(parameters, request.loginHint);
7604
+ addCcsUpn(parameters, request.loginHint);
7605
+ }
7606
+ }
7607
+ else {
7608
+ logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
7609
+ }
7610
+ if (request.nonce) {
7611
+ addNonce(parameters, request.nonce);
7612
+ }
7613
+ if (request.state) {
7614
+ addState(parameters, request.state);
7615
+ }
7616
+ if (request.claims ||
7617
+ (authOptions.clientCapabilities &&
7618
+ authOptions.clientCapabilities.length > 0)) {
7619
+ addClaims(parameters, request.claims, authOptions.clientCapabilities);
7620
+ }
7621
+ if (request.embeddedClientId) {
7622
+ addBrokerParameters(parameters, authOptions.clientId, authOptions.redirectUri);
7623
+ }
7624
+ // If extraQueryParameters includes instance_aware its value will be added when extraQueryParameters are added
7625
+ if (authOptions.instanceAware &&
7626
+ (!request.extraQueryParameters ||
7627
+ !Object.keys(request.extraQueryParameters).includes(INSTANCE_AWARE))) {
7628
+ addInstanceAware(parameters);
7629
+ }
7630
+ return parameters;
7631
+ }
7632
+ /**
7633
+ * Returns authorize endpoint with given request parameters in the query string
7634
+ * @param authority
7635
+ * @param requestParameters
7636
+ * @returns
7637
+ */
7638
+ function getAuthorizeUrl(authority, requestParameters) {
7639
+ const queryString = mapToQueryString(requestParameters);
7640
+ return UrlString.appendQueryString(authority.authorizationEndpoint, queryString);
7641
+ }
7642
+ /**
7643
+ * Helper to get sid from account. Returns null if idTokenClaims are not present or sid is not present.
7644
+ * @param account
7645
+ */
7646
+ function extractAccountSid(account) {
7647
+ return account.idTokenClaims?.sid || null;
7648
+ }
7649
+ function extractLoginHint(account) {
7650
+ return account.idTokenClaims?.login_hint || null;
7651
+ }
7652
+
7653
+ /*! @azure/msal-common v15.4.0 2025-03-25 */
7761
7654
 
7762
7655
  /*
7763
7656
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10050,7 +9943,7 @@ class ClientAssertion {
10050
9943
 
10051
9944
  /* eslint-disable header/header */
10052
9945
  const name = "@azure/msal-node";
10053
- const version = "3.3.0";
9946
+ const version = "3.4.1";
10054
9947
 
10055
9948
  /*
10056
9949
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10112,42 +10005,77 @@ class UsernamePasswordClient extends BaseClient {
10112
10005
  * @param request - CommonUsernamePasswordRequest provided by the developer
10113
10006
  */
10114
10007
  async createTokenRequestBody(request) {
10115
- const parameterBuilder = new RequestParameterBuilder();
10116
- parameterBuilder.addClientId(this.config.authOptions.clientId);
10117
- parameterBuilder.addUsername(request.username);
10118
- parameterBuilder.addPassword(request.password);
10119
- parameterBuilder.addScopes(request.scopes);
10120
- parameterBuilder.addResponseTypeForTokenAndIdToken();
10121
- parameterBuilder.addGrantType(GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
10122
- parameterBuilder.addClientInfo();
10123
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
10124
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
10125
- parameterBuilder.addThrottling();
10008
+ const parameters = new Map();
10009
+ addClientId(parameters, this.config.authOptions.clientId);
10010
+ addUsername(parameters, request.username);
10011
+ addPassword(parameters, request.password);
10012
+ addScopes(parameters, request.scopes);
10013
+ addResponseType(parameters, OAuthResponseType.IDTOKEN_TOKEN);
10014
+ addGrantType(parameters, GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
10015
+ addClientInfo(parameters);
10016
+ addLibraryInfo(parameters, this.config.libraryInfo);
10017
+ addApplicationTelemetry(parameters, this.config.telemetry.application);
10018
+ addThrottling(parameters);
10126
10019
  if (this.serverTelemetryManager) {
10127
- parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
10020
+ addServerTelemetry(parameters, this.serverTelemetryManager);
10128
10021
  }
10129
10022
  const correlationId = request.correlationId ||
10130
10023
  this.config.cryptoInterface.createNewGuid();
10131
- parameterBuilder.addCorrelationId(correlationId);
10024
+ addCorrelationId(parameters, correlationId);
10132
10025
  if (this.config.clientCredentials.clientSecret) {
10133
- parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
10026
+ addClientSecret(parameters, this.config.clientCredentials.clientSecret);
10134
10027
  }
10135
10028
  const clientAssertion = this.config.clientCredentials.clientAssertion;
10136
10029
  if (clientAssertion) {
10137
- parameterBuilder.addClientAssertion(await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
10138
- parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
10030
+ addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
10031
+ addClientAssertionType(parameters, clientAssertion.assertionType);
10139
10032
  }
10140
10033
  if (!StringUtils.isEmptyObj(request.claims) ||
10141
10034
  (this.config.authOptions.clientCapabilities &&
10142
10035
  this.config.authOptions.clientCapabilities.length > 0)) {
10143
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
10036
+ addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
10144
10037
  }
10145
10038
  if (this.config.systemOptions.preventCorsPreflight &&
10146
10039
  request.username) {
10147
- parameterBuilder.addCcsUpn(request.username);
10040
+ addCcsUpn(parameters, request.username);
10148
10041
  }
10149
- return parameterBuilder.createQueryString();
10042
+ return mapToQueryString(parameters);
10043
+ }
10044
+ }
10045
+
10046
+ /*
10047
+ * Copyright (c) Microsoft Corporation. All rights reserved.
10048
+ * Licensed under the MIT License.
10049
+ */
10050
+ /**
10051
+ * Constructs the full /authorize URL with request parameters
10052
+ * @param config
10053
+ * @param authority
10054
+ * @param request
10055
+ * @param logger
10056
+ * @returns
10057
+ */
10058
+ function getAuthCodeRequestUrl(config, authority, request, logger) {
10059
+ const parameters = getStandardAuthorizeRequestParameters({
10060
+ ...config.auth,
10061
+ authority: authority,
10062
+ redirectUri: request.redirectUri || "",
10063
+ }, request, logger);
10064
+ addLibraryInfo(parameters, {
10065
+ sku: Constants.MSAL_SKU,
10066
+ version: version,
10067
+ cpu: process.arch || "",
10068
+ os: process.platform || "",
10069
+ });
10070
+ if (config.auth.protocolMode !== ProtocolMode.OIDC) {
10071
+ addApplicationTelemetry(parameters, config.telemetry.application);
10072
+ }
10073
+ addResponseType(parameters, OAuthResponseType.CODE);
10074
+ if (request.codeChallenge && request.codeChallengeMethod) {
10075
+ addCodeChallengeParams(parameters, request.codeChallenge, request.codeChallengeMethod);
10150
10076
  }
10077
+ addExtraQueryParameters(parameters, request.extraQueryParameters || {});
10078
+ return getAuthorizeUrl(authority, parameters);
10151
10079
  }
10152
10080
 
10153
10081
  /*
@@ -10185,11 +10113,11 @@ class ClientApplication {
10185
10113
  ...(await this.initializeBaseRequest(request)),
10186
10114
  responseMode: request.responseMode || ResponseMode.QUERY,
10187
10115
  authenticationScheme: AuthenticationScheme.BEARER,
10116
+ state: request.state || "",
10117
+ nonce: request.nonce || "",
10188
10118
  };
10189
- const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, validRequest.redirectUri, undefined, undefined, request.azureCloudOptions);
10190
- const authorizationCodeClient = new AuthorizationCodeClient(authClientConfig);
10191
- this.logger.verbose("Auth code client created", validRequest.correlationId);
10192
- return authorizationCodeClient.getAuthCodeUrl(validRequest);
10119
+ const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
10120
+ return getAuthCodeRequestUrl(this.config, discoveredAuthority, validRequest, this.logger);
10193
10121
  }
10194
10122
  /**
10195
10123
  * Acquires a token by exchanging the Authorization Code received from the first step of OAuth2.0
@@ -10214,7 +10142,8 @@ class ClientApplication {
10214
10142
  };
10215
10143
  const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByCode, validRequest.correlationId);
10216
10144
  try {
10217
- const authClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, validRequest.redirectUri, serverTelemetryManager, undefined, request.azureCloudOptions);
10145
+ const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
10146
+ const authClientConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, validRequest.redirectUri, serverTelemetryManager);
10218
10147
  const authorizationCodeClient = new AuthorizationCodeClient(authClientConfig);
10219
10148
  this.logger.verbose("Auth code client created", validRequest.correlationId);
10220
10149
  return await authorizationCodeClient.acquireToken(validRequest, authCodePayLoad);
@@ -10243,7 +10172,8 @@ class ClientApplication {
10243
10172
  };
10244
10173
  const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByRefreshToken, validRequest.correlationId);
10245
10174
  try {
10246
- const refreshTokenClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, validRequest.redirectUri || "", serverTelemetryManager, undefined, request.azureCloudOptions);
10175
+ const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
10176
+ const refreshTokenClientConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, validRequest.redirectUri || "", serverTelemetryManager);
10247
10177
  const refreshTokenClient = new RefreshTokenClient(refreshTokenClientConfig);
10248
10178
  this.logger.verbose("Refresh token client created", validRequest.correlationId);
10249
10179
  return await refreshTokenClient.acquireToken(validRequest);
@@ -10272,7 +10202,8 @@ class ClientApplication {
10272
10202
  };
10273
10203
  const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent, validRequest.correlationId, validRequest.forceRefresh);
10274
10204
  try {
10275
- const clientConfiguration = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, validRequest.redirectUri || "", serverTelemetryManager, undefined, validRequest.azureCloudOptions);
10205
+ const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
10206
+ const clientConfiguration = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, validRequest.redirectUri || "", serverTelemetryManager);
10276
10207
  const silentFlowClient = new SilentFlowClient(clientConfiguration);
10277
10208
  this.logger.verbose("Silent flow client created", validRequest.correlationId);
10278
10209
  try {
@@ -10338,7 +10269,8 @@ class ClientApplication {
10338
10269
  };
10339
10270
  const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByUsernamePassword, validRequest.correlationId);
10340
10271
  try {
10341
- const usernamePasswordClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, "", serverTelemetryManager, undefined, request.azureCloudOptions);
10272
+ const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
10273
+ const usernamePasswordClientConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, "", serverTelemetryManager);
10342
10274
  const usernamePasswordClient = new UsernamePasswordClient(usernamePasswordClientConfig);
10343
10275
  this.logger.verbose("Username password client created", validRequest.correlationId);
10344
10276
  return await usernamePasswordClient.acquireToken(validRequest);
@@ -10393,14 +10325,8 @@ class ClientApplication {
10393
10325
  * @param authority - user passed authority in configuration
10394
10326
  * @param serverTelemetryManager - initializes servertelemetry if passed
10395
10327
  */
10396
- async buildOauthClientConfiguration(authority, requestCorrelationId, redirectUri, serverTelemetryManager, azureRegionConfiguration, azureCloudOptions) {
10328
+ async buildOauthClientConfiguration(discoveredAuthority, requestCorrelationId, redirectUri, serverTelemetryManager) {
10397
10329
  this.logger.verbose("buildOauthClientConfiguration called", requestCorrelationId);
10398
- // precedence - azureCloudInstance + tenant >> authority and request >> config
10399
- const userAzureCloudOptions = azureCloudOptions
10400
- ? azureCloudOptions
10401
- : this.config.auth.azureCloudOptions;
10402
- // using null assertion operator as we ensure that all config values have default values in buildConfiguration()
10403
- const discoveredAuthority = await this.createAuthority(authority, requestCorrelationId, azureRegionConfiguration, userAzureCloudOptions);
10404
10330
  this.logger.info(`Building oauth client configuration with the following authority: ${discoveredAuthority.tokenEndpoint}.`, requestCorrelationId);
10405
10331
  serverTelemetryManager?.updateRegionDiscoveryMetadata(discoveredAuthority.regionDiscoveryMetadata);
10406
10332
  const clientConfiguration = {
@@ -10502,7 +10428,7 @@ class ClientApplication {
10502
10428
  async createAuthority(authorityString, requestCorrelationId, azureRegionConfiguration, azureCloudOptions) {
10503
10429
  this.logger.verbose("createAuthority called", requestCorrelationId);
10504
10430
  // build authority string based on auth params - azureCloudInstance is prioritized if provided
10505
- const authorityUrl = Authority.generateAuthority(authorityString, azureCloudOptions);
10431
+ const authorityUrl = Authority.generateAuthority(authorityString, azureCloudOptions || this.config.auth.azureCloudOptions);
10506
10432
  const authorityOptions = {
10507
10433
  protocolMode: this.config.auth.protocolMode,
10508
10434
  knownAuthorities: this.config.auth.knownAuthorities,
@@ -10552,7 +10478,8 @@ class LoopbackClient {
10552
10478
  }
10553
10479
  const redirectUri = this.getRedirectUri();
10554
10480
  const parsedUrl = new URL(url, redirectUri);
10555
- const authCodeResponse = getDeserializedResponse(parsedUrl.search) || {};
10481
+ const authCodeResponse = getDeserializedResponse(parsedUrl.search) ||
10482
+ {};
10556
10483
  if (authCodeResponse.code) {
10557
10484
  res.writeHead(HttpStatus.REDIRECT, {
10558
10485
  location: redirectUri,
@@ -10657,11 +10584,11 @@ class DeviceCodeClient extends BaseClient {
10657
10584
  * @param request - developer provided CommonDeviceCodeRequest
10658
10585
  */
10659
10586
  createExtraQueryParameters(request) {
10660
- const parameterBuilder = new RequestParameterBuilder();
10587
+ const parameters = new Map();
10661
10588
  if (request.extraQueryParameters) {
10662
- parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
10589
+ addExtraQueryParameters(parameters, request.extraQueryParameters);
10663
10590
  }
10664
- return parameterBuilder.createQueryString();
10591
+ return mapToQueryString(parameters);
10665
10592
  }
10666
10593
  /**
10667
10594
  * Executes POST request to device code endpoint
@@ -10690,18 +10617,18 @@ class DeviceCodeClient extends BaseClient {
10690
10617
  * @param request - developer provided CommonDeviceCodeRequest
10691
10618
  */
10692
10619
  createQueryString(request) {
10693
- const parameterBuilder = new RequestParameterBuilder();
10694
- parameterBuilder.addScopes(request.scopes);
10695
- parameterBuilder.addClientId(this.config.authOptions.clientId);
10620
+ const parameters = new Map();
10621
+ addScopes(parameters, request.scopes);
10622
+ addClientId(parameters, this.config.authOptions.clientId);
10696
10623
  if (request.extraQueryParameters) {
10697
- parameterBuilder.addExtraQueryParameters(request.extraQueryParameters);
10624
+ addExtraQueryParameters(parameters, request.extraQueryParameters);
10698
10625
  }
10699
10626
  if (request.claims ||
10700
10627
  (this.config.authOptions.clientCapabilities &&
10701
10628
  this.config.authOptions.clientCapabilities.length > 0)) {
10702
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
10629
+ addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
10703
10630
  }
10704
- return parameterBuilder.createQueryString();
10631
+ return mapToQueryString(parameters);
10705
10632
  }
10706
10633
  /**
10707
10634
  * Breaks the polling with specific conditions
@@ -10791,27 +10718,27 @@ class DeviceCodeClient extends BaseClient {
10791
10718
  * @param deviceCodeResponse - DeviceCodeResponse returned by the security token service device code endpoint
10792
10719
  */
10793
10720
  createTokenRequestBody(request, deviceCodeResponse) {
10794
- const requestParameters = new RequestParameterBuilder();
10795
- requestParameters.addScopes(request.scopes);
10796
- requestParameters.addClientId(this.config.authOptions.clientId);
10797
- requestParameters.addGrantType(GrantType.DEVICE_CODE_GRANT);
10798
- requestParameters.addDeviceCode(deviceCodeResponse.deviceCode);
10721
+ const parameters = new Map();
10722
+ addScopes(parameters, request.scopes);
10723
+ addClientId(parameters, this.config.authOptions.clientId);
10724
+ addGrantType(parameters, GrantType.DEVICE_CODE_GRANT);
10725
+ addDeviceCode(parameters, deviceCodeResponse.deviceCode);
10799
10726
  const correlationId = request.correlationId ||
10800
10727
  this.config.cryptoInterface.createNewGuid();
10801
- requestParameters.addCorrelationId(correlationId);
10802
- requestParameters.addClientInfo();
10803
- requestParameters.addLibraryInfo(this.config.libraryInfo);
10804
- requestParameters.addApplicationTelemetry(this.config.telemetry.application);
10805
- requestParameters.addThrottling();
10728
+ addCorrelationId(parameters, correlationId);
10729
+ addClientInfo(parameters);
10730
+ addLibraryInfo(parameters, this.config.libraryInfo);
10731
+ addApplicationTelemetry(parameters, this.config.telemetry.application);
10732
+ addThrottling(parameters);
10806
10733
  if (this.serverTelemetryManager) {
10807
- requestParameters.addServerTelemetry(this.serverTelemetryManager);
10734
+ addServerTelemetry(parameters, this.serverTelemetryManager);
10808
10735
  }
10809
10736
  if (!StringUtils.isEmptyObj(request.claims) ||
10810
10737
  (this.config.authOptions.clientCapabilities &&
10811
10738
  this.config.authOptions.clientCapabilities.length > 0)) {
10812
- requestParameters.addClaims(request.claims, this.config.authOptions.clientCapabilities);
10739
+ addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
10813
10740
  }
10814
- return requestParameters.createQueryString();
10741
+ return mapToQueryString(parameters);
10815
10742
  }
10816
10743
  }
10817
10744
 
@@ -10872,7 +10799,8 @@ class PublicClientApplication extends ClientApplication {
10872
10799
  const validRequest = Object.assign(request, await this.initializeBaseRequest(request));
10873
10800
  const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByDeviceCode, validRequest.correlationId);
10874
10801
  try {
10875
- const deviceCodeConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, "", serverTelemetryManager, undefined, request.azureCloudOptions);
10802
+ const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
10803
+ const deviceCodeConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, "", serverTelemetryManager);
10876
10804
  const deviceCodeClient = new DeviceCodeClient(deviceCodeConfig);
10877
10805
  this.logger.verbose("Device code client created", validRequest.correlationId);
10878
10806
  return await deviceCodeClient.acquireToken(validRequest);
@@ -11217,35 +11145,35 @@ class ClientCredentialClient extends BaseClient {
11217
11145
  * @param request - CommonClientCredentialRequest provided by the developer
11218
11146
  */
11219
11147
  async createTokenRequestBody(request) {
11220
- const parameterBuilder = new RequestParameterBuilder();
11221
- parameterBuilder.addClientId(this.config.authOptions.clientId);
11222
- parameterBuilder.addScopes(request.scopes, false);
11223
- parameterBuilder.addGrantType(GrantType.CLIENT_CREDENTIALS_GRANT);
11224
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
11225
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
11226
- parameterBuilder.addThrottling();
11148
+ const parameters = new Map();
11149
+ addClientId(parameters, this.config.authOptions.clientId);
11150
+ addScopes(parameters, request.scopes, false);
11151
+ addGrantType(parameters, GrantType.CLIENT_CREDENTIALS_GRANT);
11152
+ addLibraryInfo(parameters, this.config.libraryInfo);
11153
+ addApplicationTelemetry(parameters, this.config.telemetry.application);
11154
+ addThrottling(parameters);
11227
11155
  if (this.serverTelemetryManager) {
11228
- parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
11156
+ addServerTelemetry(parameters, this.serverTelemetryManager);
11229
11157
  }
11230
11158
  const correlationId = request.correlationId ||
11231
11159
  this.config.cryptoInterface.createNewGuid();
11232
- parameterBuilder.addCorrelationId(correlationId);
11160
+ addCorrelationId(parameters, correlationId);
11233
11161
  if (this.config.clientCredentials.clientSecret) {
11234
- parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
11162
+ addClientSecret(parameters, this.config.clientCredentials.clientSecret);
11235
11163
  }
11236
11164
  // Use clientAssertion from request, fallback to client assertion in base configuration
11237
11165
  const clientAssertion = request.clientAssertion ||
11238
11166
  this.config.clientCredentials.clientAssertion;
11239
11167
  if (clientAssertion) {
11240
- parameterBuilder.addClientAssertion(await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
11241
- parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
11168
+ addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
11169
+ addClientAssertionType(parameters, clientAssertion.assertionType);
11242
11170
  }
11243
11171
  if (!StringUtils.isEmptyObj(request.claims) ||
11244
11172
  (this.config.authOptions.clientCapabilities &&
11245
11173
  this.config.authOptions.clientCapabilities.length > 0)) {
11246
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
11174
+ addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
11247
11175
  }
11248
- return parameterBuilder.createQueryString();
11176
+ return mapToQueryString(parameters);
11249
11177
  }
11250
11178
  }
11251
11179
 
@@ -11418,36 +11346,36 @@ class OnBehalfOfClient extends BaseClient {
11418
11346
  * @param request - developer provided CommonOnBehalfOfRequest
11419
11347
  */
11420
11348
  async createTokenRequestBody(request) {
11421
- const parameterBuilder = new RequestParameterBuilder();
11422
- parameterBuilder.addClientId(this.config.authOptions.clientId);
11423
- parameterBuilder.addScopes(request.scopes);
11424
- parameterBuilder.addGrantType(GrantType.JWT_BEARER);
11425
- parameterBuilder.addClientInfo();
11426
- parameterBuilder.addLibraryInfo(this.config.libraryInfo);
11427
- parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
11428
- parameterBuilder.addThrottling();
11349
+ const parameters = new Map();
11350
+ addClientId(parameters, this.config.authOptions.clientId);
11351
+ addScopes(parameters, request.scopes);
11352
+ addGrantType(parameters, GrantType.JWT_BEARER);
11353
+ addClientInfo(parameters);
11354
+ addLibraryInfo(parameters, this.config.libraryInfo);
11355
+ addApplicationTelemetry(parameters, this.config.telemetry.application);
11356
+ addThrottling(parameters);
11429
11357
  if (this.serverTelemetryManager) {
11430
- parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
11358
+ addServerTelemetry(parameters, this.serverTelemetryManager);
11431
11359
  }
11432
11360
  const correlationId = request.correlationId ||
11433
11361
  this.config.cryptoInterface.createNewGuid();
11434
- parameterBuilder.addCorrelationId(correlationId);
11435
- parameterBuilder.addRequestTokenUse(ON_BEHALF_OF);
11436
- parameterBuilder.addOboAssertion(request.oboAssertion);
11362
+ addCorrelationId(parameters, correlationId);
11363
+ addRequestTokenUse(parameters, ON_BEHALF_OF);
11364
+ addOboAssertion(parameters, request.oboAssertion);
11437
11365
  if (this.config.clientCredentials.clientSecret) {
11438
- parameterBuilder.addClientSecret(this.config.clientCredentials.clientSecret);
11366
+ addClientSecret(parameters, this.config.clientCredentials.clientSecret);
11439
11367
  }
11440
11368
  const clientAssertion = this.config.clientCredentials.clientAssertion;
11441
11369
  if (clientAssertion) {
11442
- parameterBuilder.addClientAssertion(await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
11443
- parameterBuilder.addClientAssertionType(clientAssertion.assertionType);
11370
+ addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
11371
+ addClientAssertionType(parameters, clientAssertion.assertionType);
11444
11372
  }
11445
11373
  if (request.claims ||
11446
11374
  (this.config.authOptions.clientCapabilities &&
11447
11375
  this.config.authOptions.clientCapabilities.length > 0)) {
11448
- parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
11376
+ addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
11449
11377
  }
11450
- return parameterBuilder.createQueryString();
11378
+ return mapToQueryString(parameters);
11451
11379
  }
11452
11380
  }
11453
11381
 
@@ -11587,7 +11515,8 @@ class ConfidentialClientApplication extends ClientApplication {
11587
11515
  };
11588
11516
  const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByClientCredential, validRequest.correlationId, validRequest.skipCache);
11589
11517
  try {
11590
- const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, "", serverTelemetryManager, azureRegionConfiguration, request.azureCloudOptions);
11518
+ const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, azureRegionConfiguration, request.azureCloudOptions);
11519
+ const clientCredentialConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, "", serverTelemetryManager);
11591
11520
  const clientCredentialClient = new ClientCredentialClient(clientCredentialConfig, this.appTokenProvider);
11592
11521
  this.logger.verbose("Client credential client created", validRequest.correlationId);
11593
11522
  return await clientCredentialClient.acquireToken(validRequest);
@@ -11618,7 +11547,8 @@ class ConfidentialClientApplication extends ClientApplication {
11618
11547
  ...(await this.initializeBaseRequest(request)),
11619
11548
  };
11620
11549
  try {
11621
- const onBehalfOfConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, "", undefined, undefined, request.azureCloudOptions);
11550
+ const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
11551
+ const onBehalfOfConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, "", undefined);
11622
11552
  const oboClient = new OnBehalfOfClient(onBehalfOfConfig);
11623
11553
  this.logger.verbose("On behalf of client created", validRequest.correlationId);
11624
11554
  return await oboClient.acquireToken(validRequest);
@@ -11882,19 +11812,19 @@ class ManagedIdentityRequestParameters {
11882
11812
  this.retryPolicy = retryPolicy || defaultRetryPolicy;
11883
11813
  }
11884
11814
  computeUri() {
11885
- const parameterBuilder = new RequestParameterBuilder();
11815
+ const parameters = new Map();
11886
11816
  if (this.queryParameters) {
11887
- parameterBuilder.addExtraQueryParameters(this.queryParameters);
11817
+ addExtraQueryParameters(parameters, this.queryParameters);
11888
11818
  }
11889
- const queryParametersString = parameterBuilder.createQueryString();
11819
+ const queryParametersString = mapToQueryString(parameters);
11890
11820
  return UrlString.appendQueryString(this._baseEndpoint, queryParametersString);
11891
11821
  }
11892
11822
  computeParametersBodyString() {
11893
- const parameterBuilder = new RequestParameterBuilder();
11823
+ const parameters = new Map();
11894
11824
  if (this.bodyParameters) {
11895
- parameterBuilder.addExtraQueryParameters(this.bodyParameters);
11825
+ addExtraQueryParameters(parameters, this.bodyParameters);
11896
11826
  }
11897
- return parameterBuilder.createQueryString();
11827
+ return mapToQueryString(parameters);
11898
11828
  }
11899
11829
  }
11900
11830