@azure/msal-common 14.15.0 → 15.0.0-alpha.0

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 (185) hide show
  1. package/dist/account/AccountInfo.mjs +1 -1
  2. package/dist/account/AuthToken.mjs +1 -1
  3. package/dist/account/CcsCredential.mjs +1 -1
  4. package/dist/account/ClientInfo.mjs +1 -1
  5. package/dist/account/TokenClaims.mjs +1 -1
  6. package/dist/authority/Authority.mjs +1 -1
  7. package/dist/authority/AuthorityFactory.mjs +1 -1
  8. package/dist/authority/AuthorityMetadata.mjs +1 -1
  9. package/dist/authority/AuthorityOptions.mjs +1 -1
  10. package/dist/authority/AuthorityType.mjs +1 -1
  11. package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
  12. package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
  13. package/dist/authority/OpenIdConfigResponse.mjs +1 -1
  14. package/dist/authority/ProtocolMode.mjs +1 -1
  15. package/dist/authority/RegionDiscovery.mjs +1 -1
  16. package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +1 -0
  17. package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
  18. package/dist/cache/CacheManager.d.ts +8 -37
  19. package/dist/cache/CacheManager.d.ts.map +1 -1
  20. package/dist/cache/CacheManager.mjs +10 -77
  21. package/dist/cache/CacheManager.mjs.map +1 -1
  22. package/dist/cache/entities/AccountEntity.mjs +1 -1
  23. package/dist/cache/interface/ICacheManager.d.ts +4 -4
  24. package/dist/cache/interface/ICacheManager.d.ts.map +1 -1
  25. package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
  26. package/dist/cache/utils/CacheHelpers.mjs +1 -1
  27. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  28. package/dist/client/AuthorizationCodeClient.mjs +24 -13
  29. package/dist/client/AuthorizationCodeClient.mjs.map +1 -1
  30. package/dist/client/BaseClient.d.ts +10 -3
  31. package/dist/client/BaseClient.d.ts.map +1 -1
  32. package/dist/client/BaseClient.mjs +62 -10
  33. package/dist/client/BaseClient.mjs.map +1 -1
  34. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  35. package/dist/client/RefreshTokenClient.mjs +10 -4
  36. package/dist/client/RefreshTokenClient.mjs.map +1 -1
  37. package/dist/client/SilentFlowClient.mjs +1 -1
  38. package/dist/config/ClientConfiguration.d.ts +2 -0
  39. package/dist/config/ClientConfiguration.d.ts.map +1 -1
  40. package/dist/config/ClientConfiguration.mjs +1 -1
  41. package/dist/config/ClientConfiguration.mjs.map +1 -1
  42. package/dist/constants/AADServerParamKeys.d.ts +2 -0
  43. package/dist/constants/AADServerParamKeys.d.ts.map +1 -1
  44. package/dist/constants/AADServerParamKeys.mjs +5 -3
  45. package/dist/constants/AADServerParamKeys.mjs.map +1 -1
  46. package/dist/crypto/ICrypto.mjs +1 -1
  47. package/dist/crypto/JoseHeader.mjs +1 -1
  48. package/dist/crypto/PopTokenGenerator.mjs +1 -1
  49. package/dist/error/AuthError.mjs +1 -1
  50. package/dist/error/AuthErrorCodes.mjs +1 -1
  51. package/dist/error/CacheError.mjs +1 -1
  52. package/dist/error/CacheErrorCodes.mjs +1 -1
  53. package/dist/error/ClientAuthError.mjs +1 -1
  54. package/dist/error/ClientAuthErrorCodes.mjs +1 -1
  55. package/dist/error/ClientConfigurationError.mjs +1 -1
  56. package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
  57. package/dist/error/InteractionRequiredAuthError.mjs +1 -1
  58. package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
  59. package/dist/error/JoseHeaderError.mjs +1 -1
  60. package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
  61. package/dist/error/NetworkError.d.ts +19 -0
  62. package/dist/error/NetworkError.d.ts.map +1 -0
  63. package/dist/error/NetworkError.mjs +34 -0
  64. package/dist/error/NetworkError.mjs.map +1 -0
  65. package/dist/error/ServerError.mjs +1 -1
  66. package/dist/exports-common.d.ts +2 -1
  67. package/dist/exports-common.d.ts.map +1 -1
  68. package/dist/index-browser.mjs +2 -2
  69. package/dist/index-node.mjs +2 -2
  70. package/dist/index.mjs +2 -2
  71. package/dist/logger/Logger.mjs +1 -1
  72. package/dist/network/INetworkModule.d.ts +1 -1
  73. package/dist/network/INetworkModule.d.ts.map +1 -1
  74. package/dist/network/INetworkModule.mjs +1 -1
  75. package/dist/network/NetworkResponse.d.ts +6 -0
  76. package/dist/network/NetworkResponse.d.ts.map +1 -0
  77. package/dist/network/ThrottlingUtils.d.ts +1 -1
  78. package/dist/network/ThrottlingUtils.d.ts.map +1 -1
  79. package/dist/network/ThrottlingUtils.mjs +1 -1
  80. package/dist/packageMetadata.d.ts +1 -1
  81. package/dist/packageMetadata.d.ts.map +1 -1
  82. package/dist/packageMetadata.mjs +2 -2
  83. package/dist/request/AuthenticationHeaderParser.mjs +1 -1
  84. package/dist/request/BaseAuthRequest.d.ts +2 -0
  85. package/dist/request/BaseAuthRequest.d.ts.map +1 -1
  86. package/dist/request/RequestParameterBuilder.d.ts +8 -1
  87. package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
  88. package/dist/request/RequestParameterBuilder.mjs +26 -3
  89. package/dist/request/RequestParameterBuilder.mjs.map +1 -1
  90. package/dist/request/RequestValidator.mjs +1 -1
  91. package/dist/request/ScopeSet.mjs +1 -1
  92. package/dist/response/ResponseHandler.mjs +3 -3
  93. package/dist/response/ResponseHandler.mjs.map +1 -1
  94. package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
  95. package/dist/telemetry/performance/PerformanceClient.mjs +29 -10
  96. package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
  97. package/dist/telemetry/performance/PerformanceEvent.d.ts +9 -0
  98. package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  99. package/dist/telemetry/performance/PerformanceEvent.mjs +6 -1
  100. package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
  101. package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
  102. package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
  103. package/dist/url/UrlString.mjs +1 -1
  104. package/dist/utils/ClientAssertionUtils.mjs +1 -1
  105. package/dist/utils/Constants.d.ts +1 -6
  106. package/dist/utils/Constants.d.ts.map +1 -1
  107. package/dist/utils/Constants.mjs +2 -7
  108. package/dist/utils/Constants.mjs.map +1 -1
  109. package/dist/utils/FunctionWrappers.mjs +1 -1
  110. package/dist/utils/ProtocolUtils.mjs +1 -1
  111. package/dist/utils/StringUtils.mjs +1 -1
  112. package/dist/utils/TimeUtils.mjs +1 -1
  113. package/dist/utils/UrlUtils.mjs +1 -1
  114. package/lib/index-browser.cjs +33 -13
  115. package/lib/index-browser.cjs.map +1 -1
  116. package/lib/{index-node-aee3f7b6.js → index-node-DDJMpU-A.js} +278 -260
  117. package/lib/index-node-DDJMpU-A.js.map +1 -0
  118. package/lib/index-node.cjs +5 -4
  119. package/lib/index-node.cjs.map +1 -1
  120. package/lib/index.cjs +5 -4
  121. package/lib/index.cjs.map +1 -1
  122. package/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts +1 -0
  123. package/lib/types/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -1
  124. package/lib/types/cache/CacheManager.d.ts +8 -37
  125. package/lib/types/cache/CacheManager.d.ts.map +1 -1
  126. package/lib/types/cache/interface/ICacheManager.d.ts +4 -4
  127. package/lib/types/cache/interface/ICacheManager.d.ts.map +1 -1
  128. package/lib/types/client/AuthorizationCodeClient.d.ts.map +1 -1
  129. package/lib/types/client/BaseClient.d.ts +10 -3
  130. package/lib/types/client/BaseClient.d.ts.map +1 -1
  131. package/lib/types/client/RefreshTokenClient.d.ts.map +1 -1
  132. package/lib/types/config/ClientConfiguration.d.ts +2 -0
  133. package/lib/types/config/ClientConfiguration.d.ts.map +1 -1
  134. package/lib/types/constants/AADServerParamKeys.d.ts +2 -0
  135. package/lib/types/constants/AADServerParamKeys.d.ts.map +1 -1
  136. package/lib/types/error/NetworkError.d.ts +19 -0
  137. package/lib/types/error/NetworkError.d.ts.map +1 -0
  138. package/lib/types/exports-common.d.ts +2 -1
  139. package/lib/types/exports-common.d.ts.map +1 -1
  140. package/lib/types/network/INetworkModule.d.ts +1 -1
  141. package/lib/types/network/INetworkModule.d.ts.map +1 -1
  142. package/lib/types/network/NetworkResponse.d.ts +6 -0
  143. package/lib/types/network/NetworkResponse.d.ts.map +1 -0
  144. package/lib/types/network/ThrottlingUtils.d.ts +1 -1
  145. package/lib/types/network/ThrottlingUtils.d.ts.map +1 -1
  146. package/lib/types/packageMetadata.d.ts +1 -1
  147. package/lib/types/packageMetadata.d.ts.map +1 -1
  148. package/lib/types/request/BaseAuthRequest.d.ts +2 -0
  149. package/lib/types/request/BaseAuthRequest.d.ts.map +1 -1
  150. package/lib/types/request/RequestParameterBuilder.d.ts +8 -1
  151. package/lib/types/request/RequestParameterBuilder.d.ts.map +1 -1
  152. package/lib/types/telemetry/performance/PerformanceClient.d.ts.map +1 -1
  153. package/lib/types/telemetry/performance/PerformanceEvent.d.ts +9 -0
  154. package/lib/types/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  155. package/lib/types/utils/Constants.d.ts +1 -6
  156. package/lib/types/utils/Constants.d.ts.map +1 -1
  157. package/package.json +2 -4
  158. package/src/authority/RegionDiscovery.ts +1 -1
  159. package/src/cache/CacheManager.ts +16 -130
  160. package/src/cache/interface/ICacheManager.ts +4 -4
  161. package/src/client/AuthorizationCodeClient.ts +37 -16
  162. package/src/client/BaseClient.ts +104 -22
  163. package/src/client/RefreshTokenClient.ts +14 -5
  164. package/src/config/ClientConfiguration.ts +2 -0
  165. package/src/constants/AADServerParamKeys.ts +2 -0
  166. package/src/error/NetworkError.ts +44 -0
  167. package/src/exports-common.ts +2 -5
  168. package/src/network/INetworkModule.ts +1 -1
  169. package/src/network/NetworkResponse.ts +10 -0
  170. package/src/network/ThrottlingUtils.ts +1 -1
  171. package/src/packageMetadata.ts +1 -1
  172. package/src/request/BaseAuthRequest.ts +2 -0
  173. package/src/request/RequestParameterBuilder.ts +51 -1
  174. package/src/response/ResponseHandler.ts +2 -2
  175. package/src/telemetry/performance/PerformanceClient.ts +42 -12
  176. package/src/telemetry/performance/PerformanceEvent.ts +15 -0
  177. package/src/utils/Constants.ts +1 -6
  178. package/dist/network/NetworkManager.d.ts +0 -34
  179. package/dist/network/NetworkManager.d.ts.map +0 -1
  180. package/dist/network/NetworkManager.mjs +0 -44
  181. package/dist/network/NetworkManager.mjs.map +0 -1
  182. package/lib/index-node-aee3f7b6.js.map +0 -1
  183. package/lib/types/network/NetworkManager.d.ts +0 -34
  184. package/lib/types/network/NetworkManager.d.ts.map +0 -1
  185. package/src/network/NetworkManager.ts +0 -76
@@ -82,11 +82,13 @@ export type CommonClientConfiguration = {
82
82
  * - protocolMode - Enum that represents the protocol that msal follows. Used for configuring proper endpoints.
83
83
  * - skipAuthorityMetadataCache - A flag to choose whether to use or not use the local metadata cache during authority initialization. Defaults to false.
84
84
  * - instanceAware - A flag of whether the STS will send back additional parameters to specify where the tokens should be retrieved from.
85
+ * - redirectUri - The redirect URI where authentication responses can be received by your application. It must exactly match one of the redirect URIs registered in the Azure portal.
85
86
  * @internal
86
87
  */
87
88
  export type AuthOptions = {
88
89
  clientId: string;
89
90
  authority: Authority;
91
+ redirectUri: string;
90
92
  clientCapabilities?: Array<string>;
91
93
  azureCloudOptions?: AzureCloudOptions;
92
94
  skipAuthorityMetadataCache?: boolean;
@@ -56,3 +56,5 @@ export const SID = "sid";
56
56
  export const LOGIN_HINT = "login_hint";
57
57
  export const DOMAIN_HINT = "domain_hint";
58
58
  export const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
59
+ export const BROKER_CLIENT_ID = "brk_client_id";
60
+ export const BROKER_REDIRECT_URI = "brk_redirect_uri";
@@ -0,0 +1,44 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { AuthError } from "./AuthError.js";
7
+
8
+ /**
9
+ * Represents network related errors
10
+ */
11
+ export class NetworkError extends AuthError {
12
+ error: AuthError;
13
+ httpStatus?: number;
14
+ responseHeaders?: Record<string, string>;
15
+
16
+ constructor(
17
+ error: AuthError,
18
+ httpStatus?: number,
19
+ responseHeaders?: Record<string, string>
20
+ ) {
21
+ super(error.errorCode, error.errorMessage, error.subError);
22
+
23
+ Object.setPrototypeOf(this, NetworkError.prototype);
24
+ this.name = "NetworkError";
25
+ this.error = error;
26
+ this.httpStatus = httpStatus;
27
+ this.responseHeaders = responseHeaders;
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Creates NetworkError object for a failed network request
33
+ * @param error - Error to be thrown back to the caller
34
+ * @param httpStatus - Status code of the network request
35
+ * @param responseHeaders - Response headers of the network request, when available
36
+ * @returns NetworkError object
37
+ */
38
+ export function createNetworkError(
39
+ error: AuthError,
40
+ httpStatus?: number,
41
+ responseHeaders?: Record<string, string>
42
+ ): NetworkError {
43
+ return new NetworkError(error, httpStatus, responseHeaders);
44
+ }
@@ -91,11 +91,7 @@ export {
91
91
  NetworkRequestOptions,
92
92
  StubbedNetworkModule,
93
93
  } from "./network/INetworkModule.js";
94
- export {
95
- NetworkManager,
96
- NetworkResponse,
97
- UrlToHttpRequestOptions,
98
- } from "./network/NetworkManager.js";
94
+ export { NetworkResponse } from "./network/NetworkResponse.js";
99
95
  export { ThrottlingUtils } from "./network/ThrottlingUtils.js";
100
96
  export { RequestThumbprint } from "./network/RequestThumbprint.js";
101
97
  export { IUri } from "./url/IUri.js";
@@ -140,6 +136,7 @@ export {
140
136
  createAuthError,
141
137
  } from "./error/AuthError.js";
142
138
  export { ServerError } from "./error/ServerError.js";
139
+ export { NetworkError, createNetworkError } from "./error/NetworkError.js";
143
140
  export { CacheError, CacheErrorCodes } from "./error/CacheError.js";
144
141
  export {
145
142
  ClientAuthError,
@@ -7,7 +7,7 @@ import {
7
7
  ClientAuthErrorCodes,
8
8
  createClientAuthError,
9
9
  } from "../error/ClientAuthError.js";
10
- import { NetworkResponse } from "./NetworkManager.js";
10
+ import { NetworkResponse } from "./NetworkResponse.js";
11
11
 
12
12
  /**
13
13
  * Options allowed by network request APIs.
@@ -0,0 +1,10 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export type NetworkResponse<T> = {
7
+ headers: Record<string, string>;
8
+ body: T;
9
+ status: number;
10
+ };
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { NetworkResponse } from "./NetworkManager.js";
6
+ import { NetworkResponse } from "./NetworkResponse.js";
7
7
  import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse.js";
8
8
  import {
9
9
  HeaderNames,
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-common";
3
- export const version = "14.15.0";
3
+ export const version = "15.0.0-alpha.0";
@@ -29,6 +29,7 @@ import { ShrOptions } from "../crypto/SignedHttpRequest.js";
29
29
  * - storeInCache - Object containing boolean values indicating whether to store tokens in the cache or not (default is true)
30
30
  * - scenarioId - Scenario id to track custom user prompts
31
31
  * - popKid - Key ID to identify the public key for PoP token request
32
+ * - embeddedClientId - Embedded client id. When specified, broker client id (brk_client_id) and redirect uri (brk_redirect_uri) params are set with values from the config, overriding the corresponding extra parameters, if present.
32
33
  */
33
34
  export type BaseAuthRequest = {
34
35
  authority: string;
@@ -50,4 +51,5 @@ export type BaseAuthRequest = {
50
51
  storeInCache?: StoreInCache;
51
52
  scenarioId?: string;
52
53
  popKid?: string;
54
+ embeddedClientId?: string;
53
55
  };
@@ -28,13 +28,44 @@ import {
28
28
  } from "../config/ClientConfiguration.js";
29
29
  import { ServerTelemetryManager } from "../telemetry/server/ServerTelemetryManager.js";
30
30
  import { ClientInfo } from "../account/ClientInfo.js";
31
+ import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient.js";
32
+
33
+ function instrumentBrokerParams(
34
+ parameters: Map<string, string>,
35
+ correlationId?: string,
36
+ performanceClient?: IPerformanceClient
37
+ ) {
38
+ if (!correlationId) {
39
+ return;
40
+ }
41
+
42
+ const clientId = parameters.get(AADServerParamKeys.CLIENT_ID);
43
+ if (clientId && parameters.has(AADServerParamKeys.BROKER_CLIENT_ID)) {
44
+ performanceClient?.addFields(
45
+ {
46
+ embeddedClientId: clientId,
47
+ embeddedRedirectUri: parameters.get(
48
+ AADServerParamKeys.REDIRECT_URI
49
+ ),
50
+ },
51
+ correlationId
52
+ );
53
+ }
54
+ }
31
55
 
32
56
  /** @internal */
33
57
  export class RequestParameterBuilder {
34
58
  private parameters: Map<string, string>;
59
+ private readonly performanceClient?: IPerformanceClient;
60
+ private readonly correlationId?: string;
35
61
 
36
- constructor() {
62
+ constructor(
63
+ correlationId?: string,
64
+ performanceClient?: IPerformanceClient
65
+ ) {
37
66
  this.parameters = new Map<string, string>();
67
+ this.performanceClient = performanceClient;
68
+ this.correlationId = correlationId;
38
69
  }
39
70
 
40
71
  /**
@@ -598,6 +629,19 @@ export class RequestParameterBuilder {
598
629
  );
599
630
  }
600
631
 
632
+ addBrokerParameters(params: {
633
+ brokerClientId: string;
634
+ brokerRedirectUri: string;
635
+ }): void {
636
+ const brokerParams: StringDict = {};
637
+ brokerParams[AADServerParamKeys.BROKER_CLIENT_ID] =
638
+ params.brokerClientId;
639
+ brokerParams[AADServerParamKeys.BROKER_REDIRECT_URI] =
640
+ params.brokerRedirectUri;
641
+
642
+ this.addExtraQueryParameters(brokerParams);
643
+ }
644
+
601
645
  /**
602
646
  * Utility to create a URL from the params map
603
647
  */
@@ -608,6 +652,12 @@ export class RequestParameterBuilder {
608
652
  queryParameterArray.push(`${key}=${value}`);
609
653
  });
610
654
 
655
+ instrumentBrokerParams(
656
+ this.parameters,
657
+ this.correlationId,
658
+ this.performanceClient
659
+ );
660
+
611
661
  return queryParameterArray.join("&");
612
662
  }
613
663
  }
@@ -376,7 +376,7 @@ export class ResponseHandler {
376
376
  cacheRecord.account
377
377
  ) {
378
378
  const key = cacheRecord.account.generateAccountKey();
379
- const account = this.cacheStorage.getAccount(key, this.logger);
379
+ const account = this.cacheStorage.getAccount(key);
380
380
  if (!account) {
381
381
  this.logger.warning(
382
382
  "Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache"
@@ -724,7 +724,7 @@ export function buildAccountToCache(
724
724
 
725
725
  let cachedAccount: AccountEntity | null = null;
726
726
  if (baseAccountKey) {
727
- cachedAccount = cacheStorage.getAccount(baseAccountKey, logger);
727
+ cachedAccount = cacheStorage.getAccount(baseAccountKey);
728
728
  }
729
729
 
730
730
  const baseAccount =
@@ -198,22 +198,39 @@ export function compactStack(stack: string, stackMaxSize: number): string[] {
198
198
  }
199
199
 
200
200
  const stackArr = stack.split("\n") || [];
201
- if (stackArr.length < 2) {
202
- return [];
203
- }
204
201
 
205
202
  const res = [];
206
- // Get top N stack lines
207
- for (
208
- // Skip first line as it may contain PII data
209
- let ix = Math.max(stackArr.length - stackMaxSize - 1, 1);
210
- ix < stackArr.length;
211
- ix++
203
+
204
+ // Check for a handful of known, common runtime errors and log them (with redaction where applicable).
205
+ const firstLine = stackArr[0];
206
+ if (
207
+ firstLine.startsWith("TypeError: Cannot read property") ||
208
+ firstLine.startsWith("TypeError: Cannot read properties of") ||
209
+ firstLine.startsWith("TypeError: Cannot set property") ||
210
+ firstLine.startsWith("TypeError: Cannot set properties of") ||
211
+ firstLine.endsWith("is not a function")
212
212
  ) {
213
- const line = stackArr[ix];
213
+ // These types of errors are not at risk of leaking PII. They will indicate unavailable APIs
214
+ res.push(compactStackLine(firstLine));
215
+ } else if (
216
+ firstLine.startsWith("SyntaxError") ||
217
+ firstLine.startsWith("TypeError")
218
+ ) {
219
+ // Prevent unintentional leaking of arbitrary info by redacting contents between both single and double quotes
220
+ res.push(
221
+ compactStackLine(
222
+ // Example: SyntaxError: Unexpected token 'e', "test" is not valid JSON -> SyntaxError: Unexpected token <redacted>, <redacted> is not valid JSON
223
+ firstLine.replace(/['].*[']|["].*["]/g, "<redacted>")
224
+ )
225
+ );
226
+ }
227
+
228
+ // Get top N stack lines
229
+ for (let ix = 1; ix < stackArr.length; ix++) {
214
230
  if (res.length >= stackMaxSize) {
215
231
  break;
216
232
  }
233
+ const line = stackArr[ix];
217
234
  res.push(compactStackLine(line));
218
235
  }
219
236
  return res;
@@ -630,14 +647,27 @@ export abstract class PerformanceClient implements IPerformanceClient {
630
647
  event.correlationId
631
648
  );
632
649
 
650
+ if (error) {
651
+ addError(error, this.logger, rootEvent);
652
+ }
653
+
633
654
  // Add sub-measurement attribute to root event.
634
655
  if (!isRoot) {
635
656
  rootEvent[event.name + "DurationMs"] = Math.floor(event.durationMs);
636
657
  return { ...rootEvent };
637
658
  }
638
659
 
639
- if (error) {
640
- addError(error, this.logger, rootEvent);
660
+ if (
661
+ isRoot &&
662
+ !error &&
663
+ (rootEvent.errorCode || rootEvent.subErrorCode)
664
+ ) {
665
+ this.logger.trace(
666
+ `PerformanceClient: Remove error and sub-error codes for root event ${event.name} as intermediate error was successfully handled`,
667
+ event.correlationId
668
+ );
669
+ rootEvent.errorCode = undefined;
670
+ rootEvent.subErrorCode = undefined;
641
671
  }
642
672
 
643
673
  let finalEvent: PerformanceEvent = { ...rootEvent, ...event };
@@ -116,6 +116,7 @@ export const PerformanceEvents = {
116
116
  /**
117
117
  * Time spent sending/waiting for the response of a request to the token endpoint
118
118
  */
119
+ NetworkClientSendPostRequestAsync: "networkClientSendPostRequestAsync",
119
120
  RefreshTokenClientExecutePostToTokenEndpoint:
120
121
  "refreshTokenClientExecutePostToTokenEndpoint",
121
122
  AuthorizationCodeClientExecutePostToTokenEndpoint:
@@ -342,6 +343,10 @@ export const PerformanceEventAbbreviations: ReadonlyMap<string, string> =
342
343
  PerformanceEvents.BaseClientCreateTokenRequestHeaders,
343
344
  "BaseClientCreateTReqHead",
344
345
  ],
346
+ [
347
+ PerformanceEvents.NetworkClientSendPostRequestAsync,
348
+ "NetClientSendPost",
349
+ ],
345
350
  [
346
351
  PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint,
347
352
  "RTClientExecPost",
@@ -790,7 +795,14 @@ export type PerformanceEvent = {
790
795
  matsSilentStatus?: number;
791
796
  matsHttpStatus?: number;
792
797
  matsHttpEventCount?: number;
798
+
799
+ /**
800
+ * Http POST metadata
801
+ */
793
802
  httpVerToken?: string;
803
+ httpStatus?: number;
804
+ contentTypeHeader?: string;
805
+ contentLengthHeader?: string;
794
806
 
795
807
  /**
796
808
  * Native broker fields
@@ -834,6 +846,9 @@ export type PerformanceEvent = {
834
846
  * @type {string}
835
847
  */
836
848
  retryError?: string;
849
+
850
+ embeddedClientId?: string;
851
+ embeddedRedirectUri?: string;
837
852
  };
838
853
 
839
854
  export type PerformanceEventContext = {
@@ -99,6 +99,7 @@ export const OIDC_SCOPES = [...OIDC_DEFAULT_SCOPES, Constants.EMAIL_SCOPE];
99
99
  */
100
100
  export const HeaderNames = {
101
101
  CONTENT_TYPE: "Content-Type",
102
+ CONTENT_LENGTH: "Content-Length",
102
103
  RETRY_AFTER: "Retry-After",
103
104
  CCS_HEADER: "X-AnchorMailbox",
104
105
  WWWAuthenticate: "WWW-Authenticate",
@@ -112,12 +113,6 @@ export type HeaderNames = (typeof HeaderNames)[keyof typeof HeaderNames];
112
113
  * Persistent cache keys MSAL which stay while user is logged in.
113
114
  */
114
115
  export const PersistentCacheKeys = {
115
- ID_TOKEN: "idtoken",
116
- CLIENT_INFO: "client.info",
117
- ADAL_ID_TOKEN: "adal.idtoken",
118
- ERROR: "error",
119
- ERROR_DESC: "error.description",
120
- ACTIVE_ACCOUNT: "active-account", // Legacy active-account cache key, use new key instead
121
116
  ACTIVE_ACCOUNT_FILTERS: "active-account-filters", // new cache entry for active_account for a more robust version for browser
122
117
  } as const;
123
118
  export type PersistentCacheKeys =
@@ -1,34 +0,0 @@
1
- import { INetworkModule, NetworkRequestOptions } from "./INetworkModule.js";
2
- import { RequestThumbprint } from "./RequestThumbprint.js";
3
- import { CacheManager } from "../cache/CacheManager.js";
4
- import { ServerAuthorizationTokenResponse } from "../response/ServerAuthorizationTokenResponse.js";
5
- export type NetworkResponse<T> = {
6
- headers: Record<string, string>;
7
- body: T;
8
- status: number;
9
- };
10
- export type UrlToHttpRequestOptions = {
11
- protocol: string;
12
- hostname: string;
13
- hash: string;
14
- search: string;
15
- pathname: string;
16
- path: string;
17
- href: string;
18
- port?: number;
19
- auth?: string;
20
- };
21
- /** @internal */
22
- export declare class NetworkManager {
23
- private networkClient;
24
- private cacheManager;
25
- constructor(networkClient: INetworkModule, cacheManager: CacheManager);
26
- /**
27
- * Wraps sendPostRequestAsync with necessary preflight and postflight logic
28
- * @param thumbprint
29
- * @param tokenEndpoint
30
- * @param options
31
- */
32
- sendPostRequest<T extends ServerAuthorizationTokenResponse>(thumbprint: RequestThumbprint, tokenEndpoint: string, options: NetworkRequestOptions): Promise<NetworkResponse<T>>;
33
- }
34
- //# sourceMappingURL=NetworkManager.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NetworkManager.d.ts","sourceRoot":"","sources":["../../src/network/NetworkManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAMxD,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AAEnG,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,gBAAgB;AAChB,qBAAa,cAAc;IACvB,OAAO,CAAC,aAAa,CAAiB;IACtC,OAAO,CAAC,YAAY,CAAe;gBAEvB,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY;IAKrE;;;;;OAKG;IACG,eAAe,CAAC,CAAC,SAAS,gCAAgC,EAC5D,UAAU,EAAE,iBAAiB,EAC7B,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,qBAAqB,GAC/B,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;CAqBjC"}
@@ -1,44 +0,0 @@
1
- /*! @azure/msal-common v14.15.0 2024-09-20 */
2
- 'use strict';
3
- import { ThrottlingUtils } from './ThrottlingUtils.mjs';
4
- import { AuthError } from '../error/AuthError.mjs';
5
- import { createClientAuthError } from '../error/ClientAuthError.mjs';
6
- import { networkError } from '../error/ClientAuthErrorCodes.mjs';
7
-
8
- /*
9
- * Copyright (c) Microsoft Corporation. All rights reserved.
10
- * Licensed under the MIT License.
11
- */
12
- /** @internal */
13
- class NetworkManager {
14
- constructor(networkClient, cacheManager) {
15
- this.networkClient = networkClient;
16
- this.cacheManager = cacheManager;
17
- }
18
- /**
19
- * Wraps sendPostRequestAsync with necessary preflight and postflight logic
20
- * @param thumbprint
21
- * @param tokenEndpoint
22
- * @param options
23
- */
24
- async sendPostRequest(thumbprint, tokenEndpoint, options) {
25
- ThrottlingUtils.preProcess(this.cacheManager, thumbprint);
26
- let response;
27
- try {
28
- response = await this.networkClient.sendPostRequestAsync(tokenEndpoint, options);
29
- }
30
- catch (e) {
31
- if (e instanceof AuthError) {
32
- throw e;
33
- }
34
- else {
35
- throw createClientAuthError(networkError);
36
- }
37
- }
38
- ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response);
39
- return response;
40
- }
41
- }
42
-
43
- export { NetworkManager };
44
- //# sourceMappingURL=NetworkManager.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NetworkManager.mjs","sources":["../../src/network/NetworkManager.ts"],"sourcesContent":[null],"names":["ClientAuthErrorCodes.networkError"],"mappings":";;;;;;;AAAA;;;AAGG;AA+BH;MACa,cAAc,CAAA;IAIvB,WAAY,CAAA,aAA6B,EAAE,YAA0B,EAAA;AACjE,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;KACpC;AAED;;;;;AAKG;AACH,IAAA,MAAM,eAAe,CACjB,UAA6B,EAC7B,aAAqB,EACrB,OAA8B,EAAA;QAE9B,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAE1D,QAAA,IAAI,QAAQ,CAAC;QACb,IAAI;AACA,YAAA,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,oBAAoB,CACpD,aAAa,EACb,OAAO,CACV,CAAC;AACL,SAAA;AAAC,QAAA,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,YAAY,SAAS,EAAE;AACxB,gBAAA,MAAM,CAAC,CAAC;AACX,aAAA;AAAM,iBAAA;AACH,gBAAA,MAAM,qBAAqB,CAACA,YAAiC,CAAC,CAAC;AAClE,aAAA;AACJ,SAAA;QAED,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAErE,QAAA,OAAO,QAAQ,CAAC;KACnB;AACJ;;;;"}